Iphone 如何获取UIAlertView';结果如何?

Iphone 如何获取UIAlertView';结果如何?,iphone,uialertview,Iphone,Uialertview,我实现了gamekit。现在一切都好了。但如果用户按下send,数据将立即发送到另一台iphone/ipod/ipad,并立即写入 所以现在我想为接收器实现一个确认屏幕 在我的receiveData方法(来自gamekit)中,我有一个数组。如果用户按yes,数组将被写入一个文件。如果不按yes,数组将不会被写入一个文件 #pragma mark - #pragma mark - GKreceiveData - (void) receiveData:(NSData *)d

我实现了gamekit。现在一切都好了。但如果用户按下send,数据将立即发送到另一台iphone/ipod/ipad,并立即写入

所以现在我想为接收器实现一个确认屏幕

在我的receiveData方法(来自gamekit)中,我有一个数组。如果用户按yes,数组将被写入一个文件。如果不按yes,数组将不会被写入一个文件

    #pragma mark -
    #pragma mark - GKreceiveData
    - (void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession: (GKSession *)session context:(void *)context
    {
        NSDictionary *dict = [NSKeyedUnarchiver  unarchiveObjectWithData:data];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Incoming Set" message:[NSString stringWithFormat:@"%@ wants to send you a Set named: \n\n %@",[session displayNameForPeer:peer], [dict valueForKey:@"SetName"]] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
        [alert show];
        [alert release];




    }
    - (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
        // the user clicked one of the OK/Cancel buttons
        if (buttonIndex == 0)
        {
            //NSLog(@"ok");
  //this should happen if the user presses on ok on the alertview.
        [dataArray addObject:dict]; //i can't acess "dict"


        }
        else
        {
            //NSLog(@"cancel");
        }
    }

你看到问题了吗??我能做什么

取消按钮的索引为==0

取消按钮提示:@“取消”其他按钮提示:@“确定”,无


似乎,您的OK按钮索引为1。

dict被创建为自动释放,因此它将在UIAlertView显示期间被删除。

对于给定的代码,我看不出有必要在
UIAlertView
中将您的
委托设置为self