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];

}

}

[OK]ボタンを押すと、コードが何度も繰り返されます。どうすれば1回だけ繰り返すことができますか?

4

1 に答える 1

0

同じキャンセルタイトルの別のアラートがあることがわかりました。これを押すと、同じコードが再起動されました。しかし、助けてくれてありがとう。

于 2012-05-17T18:51:44.707 に答える