0

我有这个代码:

-(IBAction)action2:(id)sender{

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm" message:@"If you press of a new group with the name you have set will be created" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles: @"Ok", nil];
[alert show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

if([title isEqualToString:@"Ok"])
{

    NSString *destDir = [NSString stringWithFormat:@"/sandbox/%@/", namegroup.text];

    NSString *filename5 = namegroup.text;
    NSString *filename6 = @"group";
    NSString *filename7 = @"groupdata";

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,       NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *getImagePath5 = [documentsDirectory stringByAppendingPathComponent:   [NSString stringWithFormat:@"%@", filename7]];

    NSMutableArray *titles = [NSMutableArray array];
    [titles addObject:filename5];

    NSMutableArray *keys = [NSMutableArray array];
    [keys addObject:filename6];

    NSDictionary *dict = [NSDictionary dictionaryWithObjects:titles forKeys:keys];

    NSString *jsonString = [dict JSONRepresentation];
    NSData *jsonData = [jsonString dataUsingEncoding: NSUTF8StringEncoding];

    [jsonData writeToFile: getImagePath5 atomically: YES];

    [[self restClient] uploadFile:filename7 toPath:destDir
                    withParentRev:nil fromPath:getImagePath5];

}

}

如果我按确定按钮,代码会一遍又一遍地重复。我怎样才能只重复1次??

4

1 回答 1

0

我发现有另一个具有相同取消标题的警报,当按下它时,它重新启动了相同的代码。不过感谢您的帮助。

于 2012-05-17T18:51:44.707 回答