按下按钮时,我正在尝试呼叫和提醒.我用这个:
-(IBAction)Add {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"add button pressed"
message:@"Add to record"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil ];
[alert show];
[alert release];
}
Run Code Online (Sandbox Code Playgroud)
好的,这里没问题,两个按钮出现,确定并取消.现在我想检测我按下哪个按钮:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 0)
{
//just to show its working, i call another alert view
UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"OK WORKIng well"
message:@"no error" delegate:nil
cancelButtonTitle:@"IWORKS"
otherButtonTitles:@"NO PRB", nil];
[alert show];
[alert release];
}
else
{
NSLog(@"cancel");
} …Run Code Online (Sandbox Code Playgroud) 我有一个像这样的plist:
<dict>
<key>11231654</key>
<array>
<string>hello</string>
<string>goodbye</string>
</array>
<key>78978976</key>
<array>
<string>ok</string>
<string>cancel</string>
</array>
Run Code Online (Sandbox Code Playgroud)
我用这个加载了plist:
NSString *path = [[NSBundle mainBundle] pathForResource:
@"data" ofType:@"plist"];
// Build the array from the plist
NSMutableArray *array3 = [[NSMutableArray alloc] initWithContentsOfFile:path];
Run Code Online (Sandbox Code Playgroud)
我怎样才能访问我的plist的每个元素?我想在plist中搜索匹配的键,而不是搜索其子项.我怎样才能做到这一点?有什么建议吗?
请提前!