NSMutableArray suddenly isn't???

Okay, so this literally was working, and now it is not.

on application start, I read in an array of defaults into an NSMutableArray (because I may need to add things on to it later):

on applicationWillFinishLaunching_(aNotification)
		set theDefaults to current application's NSUserDefaults's standardUserDefaults() 
		theDefaults's registerDefaults:{serverSettingsList:""}
		set my theSettingsList to current application's NSMutableArray's arrayWithCapacity:1 				 		  
		set my theSettingsList to theDefaults's arrayForKey:"serverSettingsList"
                my loadServerTable:(missing value)
end applicationWillFinishLaunching_

this all works correctly, as does the loadServerTable: function -

on loadServerTable:sender
		repeat with x from 1 to count of my theSettingsList
			set theItem to item x of my theSettingsList as record
			set the end of my theServerList to {theTableServerName:serverName of theItem,theTableServerURL:serverURL of theItem,theTableServerAPIKey:serverAPIKey of theItem} 
		end repeat
		my theServerTableController's removeObjects:(theServerTableController's arrangedObjects())
		my theServerTableController's addObjects:my theServerList 
		set theServerList to {} --blank out the list
	end loadServerTable:

on launch, this all runs rather nicely, bob’s your uncle. But then I try to add a new server on to things with saveSettings: -

on saveSettings:sender
		set thePrefsRecord to {serverName:my theServerName,serverURL:my theServerURL,serverAPIKey:my theServerAPIKey} 
		current application's NSLog("thePrefsRecord: %@", thePrefsRecord)
		current application's NSLog("theSettingsList: %@", theSettingsList)
		my theSettingsList's addObject:thePrefsRecord 
		theDefaults's setObject:my theSettingsList forKey:"serverSettingsList"
		my loadServerTable:(missing value) --reload table with new data
end saveSettings:

when it gets to the addObject: method, which should just shove the new record onto the end of theSettingsList, I get:

which makes no sense to me since I explicitly declared theSettingsList as NSMutableArray. The addobject feature worked at one point, it’s how I went from one to two objects in the array early on just to test writing new data into the prefs, but now it’s not?

i’m completely unsure as to what is going on here.

FYI, the data for thePrefsRecord in my test:

and the existing value of theSettingsList:

Figured it out with some help from twitter. The initial read from NSDefaults was coercing the NSMutableArray to an NSArray. So shoving the initial read into a temp array then shoving THAT into NSMutableArray via addObjectsFromArray: did the trick.

sigh.

Easier to make a mutable copy:

       set my theSettingsList to (theDefaults's arrayForKey:"serverSettingsList")'s mutableCopy()

It fails, with a an error I can’t grok:

[AppDelegate applicationWillFinishLaunching:]: missing value doesn’t understand the “mutableCopy” message. (error -1708)

That error means (theDefaults’s arrayForKey:“serverSettingsList”) is returning nil.

figured it out with some help from Nebel: I was initially defining serverSettingsList as text instead of as a list/array. Changed that and it handles nils much better