Re: complicated (I think) Binding
Re: complicated (I think) Binding
- Subject: Re: complicated (I think) Binding
- From: Mike Abdullah <email@hidden>
- Date: Sun, 12 Mar 2006 10:17:08 +0000
Thanks Ryan, I shall definitely look at that.
Mike.
On 12 Mar 2006, at 02:00, Ryan Britton wrote:
While hardcoding the sounds directory path may work, it's not
suggested. You can use something like this to get it regardless of
where it is actually at:
+ (NSString *)soundFolderForDomain:(short)domain
{
NSString *soundFolder = nil;
FSRef foundRef;
OSErr err = FSFindFolder(domain, kSystemSoundsFolderType,
kDontCreateFolder, &foundRef);
if (err != noErr)
{
return nil;
}
else
{
unsigned char path[PATH_MAX];
FSRefMakePath(&foundRef, path, sizeof(path));
soundFolder = [NSString stringWithUTF8String:(char *)path];
}
return soundFolder;
}
Then, for system sounds, you'd call it with kSystemDomain. For
local sounds, you'd call it with kLocalDomain. For user-specific
sounds, you'd call it with kUserDomain.
On Mar 11, 2006, at 5:25 PM, Mike Abdullah wrote:
I've managed to solve the thing in the end. Mmalcolm, you're
right, I was a bit of an idiot not to have considered the
NSArrayController!
I have bound it to delegate.systemSounds of Shared Application and
this seems to be doing the job nicely. Since this array should
never change its value once the application is running, I have
bound the selectedIndex of the popup button to my data object.
When it is time for my app to extract the alarm (this should only
happen once for each document in this particular case), I will
have it look up the associated filename from the systemSounds array.
Thanks very much guys,
Mike.
On 12 Mar 2006, at 00:16, mmalcolm crawford wrote:
On Mar 11, 2006, at 4:00 PM, Mike Abdullah wrote:
From your solution, I have a question. You say to bind to
selectedValue to the popup button, but that it will give me the
result minus the extension. What if I were to bind to
selectedObject instead? (I am still trying to learn what these
various options are actually for!
Binding options are documented here:
<http://developer.apple.com/documentation/Cocoa/Reference/
CocoaBindingsRef/>
An example of a pop-up list using bindings is given here:
<http://homepage.mac.com/mmalc/CocoaExamples/controllers.html>
(see "To-Dos").
I think the key point may be that I need a NSArrayController, I
hadn't really considered using one for this situation previously.
It's not clear why you would not consider the use of an array
controller to manage an array?
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden