Вот мой ItemInfo
интерфейс класса
@interface ItemInfo : NSObject {
NSString *item;
}
@property (nonatomic, copy) NSString *ipaddress;
... и реализация
@synthesize item;
- (id) initWithItem:(NSString *)someItem {
self = [super init];
if(self) {
item = someItem; // Ideally these things should happen here.
// Since item is a NSString and not NSMutableString,
// it should be sent a retain, thus
// making its refcount = 1
// Is my understanding correct?
}
return self;
}
- (void) dealloc {
[item release]; // I own 'item', so I should release it when done
[super dealloc];
}
Я использую этот класс из других источников, например:
char *str = inet_ntoa(addy->sin_addr);
ItemInfo *h = [[ItemInfo alloc] initWithItem:[NSString stringWithFormat:@"%s", str]];
ContentBrowserViewController *d
= [[ContentBrowserViewController alloc] initWithItemInfo:h];
[self.navigationController pushViewController:d animated:YES];
[h release];
[d release];
Авария, с которой я сталкиваюсь,
*** -[CFString release]: message sent to deallocated instance 0x6225570
. 0x6225570
это адрес h.item
Куда я иду не так?