Objective-C&比较两个 NSString
我试图比较 2 个 NSString 以查看它们是否匹配,但我的应用程序不断因 EXC_BAD_ACCESS 崩溃,它只向我显示程序集输出,而不是我的代码中不断崩溃的实际位置。
这是我的比较:
NSString *compareAlarm = [lblTime stringValue];
[lblTime setStringValue:[self getTime]];
if ([sAlarmTime isEqualToString:compareAlarm])
{
NSLog(@"Alarm Hit");
}
[compareAlarm release];
有人明白为什么这会失败吗?如果我注释掉 if 语句,崩溃就会停止。
提前致谢。
I am trying to compare 2 NSStrings to see if they match but my app keeps crashing with a EXC_BAD_ACCESS and it just shows me an assembly output and not the actually location within my code that it keeps crashing.
Here is my compare:
NSString *compareAlarm = [lblTime stringValue];
[lblTime setStringValue:[self getTime]];
if ([sAlarmTime isEqualToString:compareAlarm])
{
NSLog(@"Alarm Hit");
}
[compareAlarm release];
Does anyone see why this would fail? If I comment out the if statement the crash stops.
Thanks in advanced.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有保留
compareAlarm
但释放了它。you aren't retaining
compareAlarm
but you release it.