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.
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.
EXC_BAD_ACCESS
means you're trying to access data that has been freed from memory. Most likely, you forgot to retain your data
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
.
I'm not sure where the EXC_BAD_ACCESS
is coming from, but the compiler is reading [data objectForKey:@"Location"]
as an NSCFString since NSString
is a class cluster, along with other Foundation types such as NSNumber and NSArray:
Class clusters are a design pattern that the Foundation framework makes extensive use of. Class clusters group a number of private, concrete subclasses under a public, abstract superclass. The grouping of classes in this way simplifies the publicly visible architecture of an object-oriented framework without reducing its functional richness. Class clusters are based on the Abstract Factory design pattern discussed in “Cocoa Design Patterns.”
Most likely, [data objectForKey:@"Location"]
has been released one too many times and has been deallocated. This could case an error EXC_BAD_ACCESS
. You should check your memory management carefully to see that it is not being autoreleased (or manually released).