EXC_BAD_ACCESS错误
当我运行此代码时,
NSString *string = [NSString stringWithFormat:@"http://makrr.com/*****/****/*****/****/%@.mp3", [data objectForKey:@"location"]];`
我得到了 EXC_BAD_ACCESS。 [data objectForKey:@"Location"] 是一个 NSCFString。
When I run this code
NSString *string = [NSString stringWithFormat:@"http://makrr.com/*****/****/*****/****/%@.mp3", [data objectForKey:@"location"]];`
Im getting a EXC_BAD_ACCESS. [data objectForKey:@"Location"] is a NSCFString.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定
EXC_BAD_ACCESS
来自哪里,但编译器正在将[data objectForKey:@"Location"]
读取为 NSCFString,因为NSString 是一个类簇,以及其他 Foundation 类型,例如 NSNumber 和 NSArray:
最有可能的是,
[data objectForKey:@"Location"]
已被释放过多次并已被释放。这可能会出现错误EXC_BAD_ACCESS
。您应该仔细检查内存管理以确保它没有被自动释放(或手动释放)。I'm not sure where the
EXC_BAD_ACCESS
is coming from, but the compiler is reading[data objectForKey:@"Location"]
as an NSCFString sinceNSString
is a class cluster, along with other Foundation types such as NSNumber and NSArray:Most likely,
[data objectForKey:@"Location"]
has been released one too many times and has been deallocated. This could case an errorEXC_BAD_ACCESS
. You should check your memory management carefully to see that it is not being autoreleased (or manually released).EXC_BAD_ACCESS
表示您正在尝试访问已从内存中释放的数据。最有可能的是,您忘记在途中的某个地方保留data
对象,或者关键“位置”的对象被释放了太多次。如果没有更多上下文代码,很难准确判断问题出在哪里。这是一个问题,其中的一些答案很好地解释了
EXC_BAD_ACCESS.
EXC_BAD_ACCESS
means you're trying to access data that has been freed from memory. Most likely, you forgot to retain yourdata
object somewhere along the way, or the object for the key "location" was released too many times. It's hard to tell exactly what the problem is without more code for context.Here's a question with a few answers that provide good explanations of
EXC_BAD_ACCESS
.