所以我一直在調試像一個瘋狂的男人在樂器中使用NSZombiesEnabled和NSZombies。但是,使用殭屍來運行應用程序似乎可以解決我的問題。當我在儀器中運行沒有NSZombiesEnabled或NSZombies的應用程序時,它會崩潰。有關如何處理這個問題的任何想法?NSZombieEnabled防止我的應用程序崩潰
所以問題是我釋放了兩次,但似乎無法找到我在做什麼。打開NSZombieEnabled將無法幫助,因爲程序運行良好,但不會告訴我我釋放的位置。
所以我覺得我有點知道它的崩潰,我有我創建這個globalArray Singleton類:
extern NSString * const kClearDataSource;
@interface AHImageDataSource : NSObject
+ (AHImageDataSource *)sharedDataSource;
- (void) clearDataSource;
- (void) addObject:(id) object;
- (void) addObject:(id)object atIndex:(int) index;
- (int) count;
- (id) objectAtIndex:(int) index;
@end
NSString * const kClearDataSource = @"clearDataSource";
@interface AHImageDataSource()
{
NSMutableArray * imageDataSource_;
}
@property (nonatomic, retain) NSMutableArray * imageDataSource_;
@end
@implementation AHImageDataSource
@synthesize imageDataSource_;
+ (AHImageDataSource *)sharedDataSource {
static AHImageDataSource *_sharedClient = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedClient = [[self alloc] init];
});
return _sharedClient;
}
- (id)init {
self = [super init];
if (!self) {
return nil;
}
NSMutableArray * temp = [[NSMutableArray alloc] initWithCapacity:200];
self.imageDataSource_ = temp;
[temp release];
return self;
}
-(void) clearDataSource
{
if ([self.imageDataSource_ count] > 0){
[self.imageDataSource_ removeAllObjects];
}
}
- (void) addObject:(id) object
{
[self.imageDataSource_ addObject:object];
}
- (void) addObject:(id)object atIndex:(int) index
{
[self.imageDataSource_ insertObject:object atIndex:index];
}
- (int) count
{
return [self.imageDataSource_ count];
}
- (id) objectAtIndex:(int) index
{
if (index >= 0 && index < [self.imageDataSource_ count]){
return [self.imageDataSource_ objectAtIndex:index];
}
return nil;
}
- (void) dealloc
{
[super dealloc];
[imageDataSource_ release];
}
@end
在我試圖刪除所有在對象的代碼中的一個點數組,然後添加一些東西。當發生這種情況時發生崩潰。
的這部分代碼崩潰,它在執行第二次:
NSArray *arr = [response valueForKey:@"data"];
if ([arr count] > 0){
[[AHImageDataSource sharedDataSource] clearDataSource];
}
for (NSDictionary * data in arr){
AHInstagramImageData * imgData = [[AHInstagramImageData alloc] initWithData:data];
[[AHImageDataSource sharedDataSource] addObject:imgData];
[imgData release];
}
檢查此問題[http://stackoverflow.com/questions/4164233/nszombieenabled-fixes-my-app](http://stackoverflow.com/questions/4164233/nszombieenabled-fixes-my-app) –
看到帖子,根本沒有幫助 – adit