I’m having a problem with NSString. I feel like it’s a pretty simple thing to figure out but I’ve been staring at it for a while and just can’t seem to get anywhere :/ Your help is highly appreciated!
I defined a class called Painting.
Here is Painting.h:
@interface Painting : NSObject {
NSString *artist;
UIImage *image;
}
@property (nonatomic, copy) NSString *artist;
@property (nonatomic, copy) UIImage *image;
@end
Here is Painting.m:
@implementation Painting
@synthesize artist, image;
@end
In a .h file for a view controller, I create a “painting”:
Painting *monet;
@property (nonatomic, retain) Painting *monet;
Now, in it’s .m file, I’m trying to do a very very simple print and it won’t work. I get (null) instead of “Monet”.
monet.artist = @"Monet";
NSString *bob3 = monet.artist;
NSLog(@"Real artist: %@", bob3);
However, this does work (gives me “Monet” instead of (null)):
NSString *bob3 = @"Monet";
NSLog(@"Real artist: %@", bob3);
What am I missing??
You probably need before:
this: