-2

我有一个字符串,当我比较它时,它在 NSLog 中显示以下 ling 它总是在其他地方运行

插入的记录:-1

如果数据等于给定文本,如何使其工作,否则明智地运行

        NSLog(@"%@ ",data);


if ([data isEqualToString:@"Records inserted: -1"]) {


    NSString*messageShow=[NSString stringWithFormat:@"Title name %@ already been added to Library",titleNameShow];

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:messageShow delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];


}

else {



NSString*messageShow=[NSString stringWithFormat:@"%@ added to Library",titleNameShow];



UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:messageShow delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
4

1 回答 1

1

你确定没有空格NSStrind* data吗?

尝试;

NSLog(@"|%@|",data);

并检查返回的字符串,它应该是:|插入的记录:-1|

于 2013-06-19T09:29:05.243 回答