How to get a UIAlertView's result??

Posted by cocos2dbeginner on Stack Overflow See other posts from Stack Overflow or by cocos2dbeginner
Published on 2011-01-09T13:36:52Z Indexed on 2011/01/09 13:53 UTC
Read the original article Hit count: 180

Filed under:
|

Hi,

I implemented the gamekit. All works fine now. But if the user presses on send the data will instantly send to the other iphone/ipod/ipad and it will instantly written.

So now i wanted to implemenr a confirm screen for the receiver.

In my receiveData method (from the gamekit) i have an array. If the user presses yes the array will be written into a file.if not it wont be written into a file.

    #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");
        }
    }

Do you see the problem?? What can I do??

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uialertview