I have a class (USER) which has the following properties (NSString name, NSString address, NSMutableArray tags). The tags property is an NSMutableArray of (TAG) - TAG is a class defined as (NSNumber tagId, NSString tagName).
I have tried a few different ways to access the tagName and tagId however have been unsuccessful.
Example code 1 below:
Tag *tag = [[Tag alloc] init];
for(NSInteger n = 0; n < [thisSpotTag count]; n++)
{
NSLog(@"%@", [thisSpotTag objectAtIndex:n]);
}
Example code 2 below:
NSEnumerator *enumerator = [thisSpotTag objectEnumerator];
NSString *tname = nil;
while((tname = [enumerator nextObject]))
{
NSLog(@"%@", tname);
}
In both examples, I get the memory address of the tag, but not the value of the tagName and tagId.
How do I access this information?
PS - I am using xCode 4.2 with ARC.
Update on my question below:
I'm back, and tried a few of the suggested fixes below however I still cannot get the data out of the array. Remember, I have an array of objects in which each object contains an array of objects.
I have this code for example:
NSEnumerator *enumerator = [thisUser.tags objectEnumerator];
Tag *tagObj = [[Tag alloc] init];
while(tagObj = [enumerator nextObject])
{
NSLog(@"enumerated tag id:%@ name:%@", tagObj.tid, tagObj.name);
}
I never make it into the while loop in the code above...
thisUser.tag is the TAG object for portion of a USER object. Perhaps typing out what the array looks like would help explain the nesting.
NSMutableArray( "this is an NSMutableArray of USER objects"
element 0 => USER Object 1
USER.name is an NSString
USER.address is an NSString
USER.tag "this is an NSMutableArray of TAG objects"
element 0 => TAG Object 1
TAG.tagId is an NSNumber
TAG.tagName is an NSString
element 1 => TAG Object 2
...etc...
element 1 => USER Object 2
...etc...