im pretty new to xcode, so sorry if these are basics but im having the next issue: i have a class Data that contains string friendID and string friendName.
then i also have an array dataArray of these classes. now how do i access an ID or Name inside the array of classes?
this doesnt seem to work and i cant find any other solution:
[[dataArray objectAtIndex:i] valueForKey:@"friendID"]
and if its relevant, i made dataArray like this and it works:
if(friendDataEmpty==YES)
{
NSMutableArray *tmpFriendID = [data valueForKey:@"id"]; // parsed data
NSMutableArray *tmpFriendName = [data valueForKey:@"name"]; // parsed data
for(int i=0;i<[tmpFriendID count];i++)
{
Data *data = [[Data alloc]init];
data.friendID = [tmpFriendID objectAtIndex:i];
data.friendName = [tmpFriendName objectAtIndex:i];
[dataArray addObject:data];
[data release];
}
}
and thats the header of data
@interface data : NSObject {
NSString *friendID;
NSString *friendName;
}
@property (nonatomic, copy) NSString *friendID;
@property (nonatomic, copy) NSString *friendName;
Try it like this.
Side Note: You should consider following the proper naming convention while you name your classes, methods, vars and other things. The “data” class should have been named “Data“.