Pop-up Buttons

OK, I think I have my user defaults mostly working and bound to my UI elements. Three questions that I have not found answers to:

  1. Can I create a separator in my list for a pop-up button. If so how?

  2. I have bindings set up for my pop-up button. They are :

This seems to work, but I could also use selected index, selected tag, and selected value. Can someone explain these to me a bit more, I read Apple’s Cocoa Bindings PDF which helped me a bit, but seems to leave out a lot of information on what the possible binding option actually are. The index seems logically to be the index of the item in the list, but tag and value represent what? The selected Tag option seems to work fine on another pop-up, but then I have not switched the list out on that one.

  1. I have my bindings set up in interface builder. In my application script I set up my initial values:
on will finish launching theObject
	try
		tell user defaults
			(* Documnent Group *)
			(* Page Group *)
			make new default entry at end of default entries with properties {name:"PageSizes", content:{"Letter", "Tabloid"}}
			make new default entry at end of default entries with properties {name:"PagePreset", content:"Tabloid"}
			make new default entry at end of default entries with properties {name:"PageWidth", content:11}
			make new default entry at end of default entries with properties {name:"PageHeight", content:17}
			make new default entry at end of default entries with properties {name:"FacingPages", content:0}
			(* Labels Group *)
			make new default entry at end of default entries with properties {name:"FontList", content:{"Arial"}}
			make new default entry at end of default entries with properties {name:"FontName", content:"Arial"}
			make new default entry at end of default entries with properties {name:"FontSizeList", content:{7, 8, 9, 10, 11, 12}}
			make new default entry at end of default entries with properties {name:"FontSize", content:10}
			make new default entry at end of default entries with properties {name:"FontLeadingList", content:{7, 8, 9, 10, 11, 12}}
			make new default entry at end of default entries with properties {name:"FontLeading", content:12}
		end tell
	end try
end will finish launching

Since the UI elements are bound to these defaults they update the defaults as they change. I will add a will quit handler to call:

call method "synchronize" of object user defaults

This should make sure that the user defaults are stored when the application closes so that the values are persistent between launches. Do I understand this correctly and is there anything else that I need to do?

Thanks,
Jerome

Another question, how do I clear the user defaults? I think that I set one of them to an invalid value and now it won’t build. I’m getting this in the console when trying to run the application:

I think it might have something to do with some code that I was using to change the value of a user default, but the application is holding on to the defaults between builds so it won’t revert to the original values. If there is a file I can edit or delete to see if this will fix it that would be great.

Well, I tried deleting the shared user defaults and setting things up again. It worked until I started setting the bindings, then the error comes up again. I tried reverting to an earlier version and it won’t even build. Any ideas?

In case anyone is interested, it seems that you cannot make a separator item in the menu of a popup button. This is a read only property and even when making the menu item you cannot set this property of the menu item. So my nice binding of the list of menu items will not work if I want to have a separator item in the list. I can however programatically create one using make new menu item before and after.

I never figured out the cause of the problems I was having, ended up making a new project file and rebuilding it. If anyone knows how I can “look” at the user default settings in Xcode please let me know, I can’t find any reference to where these are stored, how to reset them for the next build, or if I can look at the stored values. From previous reading it sounded like these were stored in a plist file that I could open, but it appears more like a “black box”. I build a handler to reset them to a base which works OK for now, and I’m duping my project file more often in case I run into the same problem so I don’t have to rebuild the project again.