我有一个 void 函数,当按下按钮时会获取一个名为 number 的变量。但是我有另一个函数,我想在其中使用该变量。
这是代码,因此您可以了解我的意思。
-(void)pictureListMainTableCell:(PictureListMainTableCell *)cell wantsToCallNumber:(NSString *)number
{
if([MFMessageComposeViewController canSendText])
{
MFMessageComposeViewController *messageComposer =
[[MFMessageComposeViewController alloc] init];
NSString *message = (@"%@", [self deviceLocation]);
[messageComposer setBody:message];
messageComposer.recipients = [NSArray arrayWithObjects:number , nil];
messageComposer.messageComposeDelegate = self;
[self presentViewController:messageComposer animated:YES completion:nil];
NSLog(@"Texting telephone number [%@]", messageComposer);
}
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
switch (result) {
case MessageComposeResultCancelled:
NSLog(@"Cancelled");
break;
case MessageComposeResultFailed:
NSLog(@"Failed");
break;
default:
break;
}
if (MessageComposeResultSent) {
NSString *urlString = [NSString stringWithFormat:@"telprompt://%@", number];
NSLog(@"calling telephone number [%@]", number);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
}
[self dismissModalViewControllerAnimated:YES];
}
所以我想要的是能够在第二个 void 中使用名为 number 的变量。任何帮助将不胜感激。