Reputation: 32247
#import <UIKit/UIKit.h>
@interface LoginViewController : UIViewController <UITextFieldDelegate>
@property (nonatomic, retain) NSDictionary *_data;
@end
#import "LoginViewController.h"
#import "XMLReader.h"
@implementation LoginViewController
static NSDictionary *_raceInformation;
@synthesize _data, bibInput, lastNameInput, error;
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
NSError *e = [NSError alloc];
NSString *xml = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"testhalfmarathon" ofType:@"xml"] encoding:NSUTF8StringEncoding error:&e];
NSDictionary *asdf = [XMLReader dictionaryForXMLString:xml error:nil];
self._data = [XMLReader dictionaryForXMLString:xml error:nil];
//[xml release];
//[e release];
// !! BREAKPOINT HERE
}
return self;
}
When I hit the breakpoint, the value for self._data
is nil
. However, the value for asdf
is the correct dictionary value I would expect in self._data
. What gives?
backstory: I'm a n00b when it comes to MRC
as I usually use ARC
/GC
languages.
Upvotes: 0
Views: 252
Reputation: 41005
What line of code did you put the breakpoint against? If it was just a blank line it will actually break at the previous valid line of code, which may have been before self._data was set.
Try putting NSLog(@"data %@", self._data); instead of your breakpoint and see what gets logged.
BTW, I see you had [xml release], which you commented out, presumably because it wasn't working. The reason this line is wrong is that [XMLReader dictionaryForXMLString...] returns an autoreleased object that shouldn't be released again.
In general, in Objective-C if a method name doesn't begin with "new", "alloc" or "copy" then it returns an autoreleased object that you don't need to release yourself.
Upvotes: 1