• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Saving NSDictionary, Enumeration error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving NSDictionary, Enumeration error


  • Subject: Re: Saving NSDictionary, Enumeration error
  • From: Tamas Nagy <email@hidden>
  • Date: Tue, 07 May 2013 16:04:56 +0200

The data collecting and save happening on the main thread, but the objects providing the data may run on an other - rendering - thread. Maybe its a problem with an object while collecting the save data, and I forgot about copy the value?

So, in other words, I should always do this:
[tempdict setObject:[[something copy] autorelease] forKey:…] but I forgot it somewhere and I doing [tempdict setObject:something forKey:…]. Could this be a problem?


On May 7, 2013, at 3:45 PM, Igor Elland <email@hidden> wrote:

> Cab you provide a bit more detail? Is everything happening on to main thread?
>
> On May 7, 2013, at 14:39, Tamas Nagy <email@hidden> wrote:
>
>> Hi,
>>
>> one of my users recently got an error when trying to save. My application is not document based, and I'm collecting the data to NSDictionaries, then save it with writeToFile: method. I never can reproduce the issue, so hard to find what is the problem.
>>
>> I'm collection the data with methods like:
>>
>>   NSMutableDictionary *tempdict = [[[NSMutableDictionary alloc] init] autorelease];
>>
>>   [tempdict setObject:... forKey:...];
>>   [tempdict setObject:... forKey:...];
>>   [tempdict setObject:... forKey:...];
>>       .
>>   .
>>   .
>>   return [NSDictionary dictionaryWithDictionary:tempdict];
>>
>> and putting those NSDictionaries to realSaveDict, then save:
>> [realSaveDict writeToFile:[sPanel filename] atomically:YES]
>>
>> Any ideas guys what's going wrong?
>>
>> Thanks,
>>
>> Tamas
>>
>> May 3, 2013 2:44:54 PM: *** Collection <__NSDictionaryM: 0x1c37a300> was mutated while being enumerated.
>> May 3, 2013 2:44:54 PM: (
>>   0   CoreFoundation                      0x98912e9b __raiseError + 219
>>   1   libobjc.A.dylib                     0x970b352e objc_exception_throw + 230
>>   2   CoreFoundation                      0x98912a9a __NSFastEnumerationMutationHandler + 282
>>   3   CoreFoundation                      0x9884afc9 -[__NSFastEnumerationEnumerator nextObject] + 457
>>   4   CoreFoundation                      0x98884f4c -[NSDictionary countByEnumeratingWithState:objects:count:] + 396
>>   5   CoreFoundation                      0x98884c68 -[NSDictionary __apply:context:] + 104
>>   6   CoreFoundation                      0x9880904a CFDictionaryApplyFunction + 106
>>   7   CoreFoundation                      0x98809dbe __CFPropertyListIsValidAux + 366
>>   8   CoreFoundation                      0x9882aac1 __CFPropertyListIsDictPlistAux + 257
>>   9   CoreFoundation                      0x98884cd5 -[NSDictionary __apply:context:] + 213
>>   10  CoreFoundation                      0x9880904a CFDictionaryApplyFunction + 106
>>   11  CoreFoundation                      0x98809dbe __CFPropertyListIsValidAux + 366
>>   12  CoreFoundation                      0x9882aac1 __CFPropertyListIsDictPlistAux + 257
>>   13  CoreFoundation                      0x98884cd5 -[NSDictionary __apply:context:] + 213
>>   14  CoreFoundation                      0x9880904a CFDictionaryApplyFunction + 106
>>   15  CoreFoundation                      0x98809dbe __CFPropertyListIsValidAux + 366
>>   16  CoreFoundation                      0x9882aac1 __CFPropertyListIsDictPlistAux + 257
>>   17  CoreFoundation                      0x98884cd5 -[NSDictionary __apply:context:] + 213
>>   18  CoreFoundation                      0x9880904a CFDictionaryApplyFunction + 106
>>   19  CoreFoundation                      0x98809dbe __CFPropertyListIsValidAux + 366
>>   20  CoreFoundation                      0x9882aac1 __CFPropertyListIsDictPlistAux + 257
>>   21  CoreFoundation                      0x98884cd5 -[NSDictionary __apply:context:] + 213
>>   22  CoreFoundation                      0x9880904a CFDictionaryApplyFunction + 106
>>   23  CoreFoundation                      0x98809dbe __CFPropertyListIsValidAux + 366
>>   24  CoreFoundation                      0x9883c445 CFPropertyListIsValid + 117
>>   25  CoreFoundation                      0x9883c2dd _CFPropertyListCreateXMLData + 77
>>   26  CoreFoundation                      0x9883c280 CFPropertyListCreateXMLData + 32
>>   27  Foundation                          0x98ca14ae -[NSDictionary(NSDictionary) writeToURL:atomically:] + 242
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Saving NSDictionary, Enumeration error
      • From: Jens Alfke <email@hidden>
References: 
 >Saving NSDictionary, Enumeration error (From: Tamas Nagy <email@hidden>)
 >Re: Saving NSDictionary, Enumeration error (From: Igor Elland <email@hidden>)

  • Prev by Date: Wanted: new owner for Mac apps
  • Next by Date: Re: Wanted: new owner for Mac apps
  • Previous by thread: Re: Saving NSDictionary, Enumeration error
  • Next by thread: Re: Saving NSDictionary, Enumeration error
  • Index(es):
    • Date
    • Thread