Thanks for your help on this one.
I am pulling a NSDictionary from a plist in my main bundle and am having troubles. Here is the code:
- (void)viewDidLoad {
// Pull in FAQ from Plist
NSString *strFAQPlist = [[NSBundle mainBundle] pathForResource:@"FAQs" ofType:@"plist"];
dictFAQList = [[NSDictionary alloc] initWithContentsOfFile: strFAQPlist];
// Create indexed array to hold the keys
arrFAQKeys = [[dictFAQList allKeys] retain];
// Release local vars
[strFAQPlist release];
[super viewDidLoad];
}
I feel like I should release NSString as I have already. The problem is, when I do so, I get an EXC_BAD_ACCESS error. When I comment that release out, everything works fine. Can someone explain to 开发者_StackOverflow社区me why this is ocurring?
Thanks in advance!
pathForResource
returns an autoreleased NSString
.
Only call release if you've called an alloc/init method, copy method or retained it explicitly.
If you didn't create an object directly (or retained it) don't release it.
精彩评论