This is the first time I've used a for loop in iOS! Hurrah!
Please note that "bookTitle" is an NSString object within the class. When this class initiates it takes a String argument and sets bookTitle to that.
books = [[NSMutableArray alloc] initWithObjects:
[[Book alloc] initWithTitle:@"What a great title" andAuthor:@"R Crimson"],
[[Book alloc] initWithTitle:@"What another great title" andAuthor:@"R Crimson"],
nil ];
NSUInteger count = [books count];
for(NSUInteger i= 0; i < count;i++){
Book *tb= [books objectAtIndex:i];
if(tb.title=bookTitle){
nameLabel.text=tb.title;
}
Sadly both tb.title and bookTitle are null. What should happen is that any object in the array that has a title that matches bookTitle should then have its title assigned to the nameLabel.
So I'm wondering where I've gone wrong, and also if there's a better solution? Because the title attribute isn't a unique identifier, so if I add two objects with the same title to books (unlikely that I ever would, but still!) it'll then return multiple objects, which is no good.
Thanks in advance.