2
我有一個自定義對象:Vendor
,它的範圍是NSObject
。我開始像這樣:創建後自定義對象爲空
NSDictionary *vendorObj = [vendors objectAtIndex:i];
Vendor *vendor = [[Vendor alloc] initWithVendorInfo:vendorObj];
NSLog(@"VendorObj: %@", vendorObj);
NSLog(@"Vendor: %@", vendor);
這裏是一流的樣子:
@interface Vendor : NSObject
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *description;
- (id)initWithVendorInfo:(NSDictionary *)vendorDetails;
@end
@implementation Vendor
- (id)initWithVendorInfo:(NSDictionary *)vendorDetails
{
self = [super init];
if(self)
{
_name = [vendorDetails[@"company_name"] copy];
_description = [vendorDetails[@"description"] copy];
}
return self;
}
如果我的NSLog vendorObj
所有的細節都在那裏。一旦我開始Vendor
對象和它的NSLog,日誌顯示:
2013-11-21 22:22:44.769 [48202:a07] Vendor:
我似乎無法弄清楚,爲什麼我的目標是什麼,沒有的內存地址,甚至沒有空。我在這裏做錯了什麼?
優秀!我應該看到這一點。非常感謝 – brenjt