• 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: NSUserDefaults, an array, and SIGBUS 10
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUserDefaults, an array, and SIGBUS 10


  • Subject: Re: NSUserDefaults, an array, and SIGBUS 10
  • From: Michael Mulligan <email@hidden>
  • Date: Mon, 29 Jul 2002 18:50:46 -0400

Actually disregard that last email....I just suck at pressing apple-s


Hee hee, thank you! :-)


On 07/29/02 6:46 PM, "Michael Mulligan" <email@hidden> wrote:

> I modified my code accordingly so that each Service object is archived into an
> NSData form, and then the NSData is put into the array. I would think that
> this would be enough, seeing how NSUserDefaults claims support for arrays?
>
> But no such luck. My app still crashes with the same error on the same line.
> :-(
>
> Any more ideas?
>
>
> On 07/29/02 1:59 AM, "Scott Anguish" <email@hidden> wrote:
>
>> UserDefaults can't archive your custom objects.. it only knows how to
>> handle a small number of items
>>
>>
>> instead you'd need to archive your object to an NSData and THEN add the
>> NSData to the defaults.. you'll need to reverse the operation when you
>> load..
>>
>> this category on NSUserDefaults adds support for archiving NSColor.. you
>> can see from this how to archive your own data
>>
>>
>> - (void)setColor:(NSColor *)color forKey:(NSString *)key
>> {
>> NSData *data=[NSArchiver archivedDataWithRootObject:color];
>> [self setObject:data forKey:key];
>> }
>> - (NSColor *)colorForKey:(NSString *)key
>> {
>> NSData *data=[self dataForKey:key];
>> return (NSColor *)[NSUnarchiver unarchiveObjectWithData:data];
>> }
>>
>> On Sunday, July 28, 2002, at 11:04 PM, Michael Mulligan wrote:
>>
>>> I have a PreferencesController object that brings up a window where the
>>> user
>>> fills in some data (to create or modify the settings on a Service
>>> object).
>>> When they hit the Save button, it invokes the method I've attached below
>>> (saveService). What this does in a nutshell, is we have an array filled
>>> with
>>> Service objects stored in our NSUserDefaults. So this method checks if
>>> we're
>>> editting an old Service or creating a new one, replaces the object (or
>>> adds
>>> a new one), and then attempts to write this modified array back to the
>>> preferences. The problem is that when it hits the line that should save
>>> it
>>> to the preferences, my app crashes with a SIGBUS 10. I have no idea why
>>> this
>>> is happening--every object involved with the line in question seems to
>>> still
>>> be in memory (I've output their values to check).
>>>
>>> And here's the weird part. If I output [[NSUserDefaults
>>> standardUserDefaults] objectForKey:mikeServices] *after* I alter the
>>> visibleServices array but *before* I save it to the UserDefaults, it
>>> shows
>>> the changes. However, it does not save them to the actual preferences.
>>> So I
>>> know I must be doing something funky with my memory references, but I
>>> have
>>> tried everything and have no idea what I'm doing wrong. :-(
>>
>
>
> -m^2
>
> __________
> Hi! I'm a .signature virus! Copy me into your ~/.signature to help me spread!
> __________
>


-m^2

__________
Hi! I'm a .signature virus! Copy me into your ~/.signature to help me
spread!
__________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSUserDefaults, an array, and SIGBUS 10 (From: Michael Mulligan <email@hidden>)

  • Prev by Date: Re: NSUserDefaults, an array, and SIGBUS 10
  • Next by Date: Re: [NSOpenPanel openPanel] problems
  • Previous by thread: Re: NSUserDefaults, an array, and SIGBUS 10
  • Next by thread: Re: NSUserDefaults, an array, and SIGBUS 10
  • Index(es):
    • Date
    • Thread