I have the following DataAll.plist:
<array>
<dict>
<key>ID</key>
<integer>1</integer>
<key>Name</key>
<string>Inigo Montoya</string>
</dict>
....
</array>
I want to get the ID value from it. My code gets the Name correctly, but the ID is a weird value. Here's what I'm doing:
NSBundle *bundle = [NSBundle mainBundle];
NSString *plistPath = [bundle pathForResource:@"DataAll" ofType:@"plist"];
NSArray *array = [[NSArray alloc] initWithContentsOfFile:plistPath];
self.allData = array;
[array release];
NSDictionary *first = [[NSDictionary alloc]
initWithDictionary:[self.allData objectAtIndex:0]];
Data *firstData = [[Data alloc] init];
[firstData setData:first];
labelName.text = [firstData EXName];
labelID.text = [NSString stringWithFormat:@"%d",[[firstData EXID]];
[firstData release];
Here's my Data.h
@interface Data : NSObject {
NSNumber *EXID;
NSString *EXName;
}
@property (readwrite, retain) NSNumber *EXID;
@property (nonatomic, retain) NSString *EXName;
And Data.m
@implementation Data
@synthesize EXID;
@synthesize EXName;
- (void) setData: (NSDictionary *) dictionary {
self.EXName = [dictionary objectForKey:@"Name"];
NSNumber *ID = [dictionary objectForKey:@"ID"];
self.EXID = ID;
}
Many thanks in advance! This is my first post, so I apologize if formatting isn't correct.