Hi,
This should be easy for someone.
In my viewcontroller I'm accessing an object called reader which parses some xml and stores them in an array of post objects. So far this all works because i can loop through the objects and display data about each object in the console.
Im my viewcontroller I'm trying to get the post object to return the array of objects, but no matter what I do nothing seems to be working.
in my view controller I have...
- (void)viewDidLoad
{
// Initialise reader object
Reader *myReader = [[Reader alloc] initWithPath:@"feed.xml"];
// Get posts from the reader
self.posts = [[NSArray alloc] initWithArray:[myReader giveMeThePosts]];
NSLog(@"Post count = %i",[myReader.posts count]);
for (Post* post in self.posts) {
NSLog(@"Title=%@", post.title);
}
// Release myReader, we're finished with it
[myReader release];
[super viewDidLoad];
}
and here is the giveMeThePosts method that's in the reader object
-(NSArray*)giveMeThePosts
{
// Put posts into a local array
NSArray *thePosts = [[NSArray alloc] initWithArray:self.posts];
NSLog(@"The Count: %i",[thePosts count]);
// Return the array
return [thePosts autorelease];
}
and this point it's worth noting that the NSLog bit in the above function doesn't appear at all, as if the function isn't being ran.
Can anyone point me in the direction of where I'm going wrong?
Open in new window