I have class containing
.h file.
@interface NewsItem : NSObject
{
NSString* _newsID;
NSString* _newsTitle;
NSString* _imageURL;
NSString* _description;
}
@property (nonatomic, copy) NSString* newsID;
@property (nonatomic, retain) NSString* newsTitle;
@property (nonatomic, copy) NSString* imageURL;
@property (nonatomic, copy) NSString* description;
.m file
@implementation NewsItem
@synthesize newsID= _newsID;
@synthesize newsTitle= _newsTitle;
@synthesize imageURL = _imageURL;
@synthesize description= _description;
Whenever I print the object of newsItem from breakpoint, the value of description field is displayed instead of object reference address. Why so ?
Help Please, Thanks in advance.
You have made the [NSObject description]
method a property. Remove _description
and @property description
and implement the description
method yourself:
- (NSString *)description {
return [NSString stringWithFormat:@"newsID=%@, newsTitle=%@, imageURL=%@", self.newsID, self.newsTitle, self.imageURL];
}
This method will then be called whenever you do the following:
NSLog(@"%@", newsItem);