문제

Sorry... shame - I didn't run debug mode so the error showed up on the wrong line. In debug-mode, and showing the right line, the error was a simple "dont access an array outside its bounds"-error (typo - i referred to one array but access was to another)


Why does accessing the count of an NSMutableArray produce SIGABRT when I empty the NSMutableArray from another thread? I thought the @synchronized was supposed to do as it's name implies?

NSMutableArray *sourceImageRepArray;

...

@synchronized(self)
{
   NSLog(@"singleton 1 %p", self);
   unsigned long count = sourceImageRepArray.count; //SIGABRT here!
   ...

Don't know how much extra code you want me to share... this is the code that triggers it:

@synchronized([Singleton sharedSingleton])
{
   NSLog(@"singleton 2 %p", [Singleton sharedSingleton]);
   int i, n;
   n = [filenames count];
   for(i=0; i<n; i++){
      ImageRep *item = [[ImageRep alloc] init];
      [item setPath:[filenames objectAtIndex:i]];   
      [[Singleton sharedSingleton].targetImageRepArray insertObject:item atIndex: [targetImageBrowser indexAtLocationOfDroppedItem]];
      [item release];
      [[Singleton sharedSingleton] removeImageRepFromArray:[Singleton sharedSingleton].sourceImageRepArray withPath:[filenames objectAtIndex:i]];
   }
}

singleton 1 == singleton 2:

2011-02-08 07:22:03.265 Crash[60001:5d03] singleton 1 0x200047680
2011-02-08 07:22:03.433 Crash[60001:a0f] singleton 2 0x200047680
  • why is it not synchronizing?! What else could be going on?

올바른 솔루션이 없습니다

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top