PROBLEMS POPULATING A POP-UP MENU IN A WINDOW
PROBLEMS POPULATING A POP-UP MENU IN A WINDOW
- Subject: PROBLEMS POPULATING A POP-UP MENU IN A WINDOW
- From: email@hidden
- Date: Tue, 3 Feb 2004 03:27:03 EST
Here is all of the code in case you wish to test the routine.
Someone game me a line to insert (see code) but it doesn't work, I also need
a way to set the selected item to "ActiveDevice".
In the header file "IBOutlet id populate;" is asigned and corresponds to the
pop-up menu.
_______________________________________________
static char* Copy_CFStringRefToCString(const CFStringRef pCFStringRef)
{
char* results = NULL;
if (NULL != pCFStringRef)
{
CFIndex length = sizeof(UniChar) * CFStringGetLength(pCFStringRef) + 1
;
results = (char*) NewPtrClear(length);
if
(!CFStringGetCString(pCFStringRef,results,length,kCFStringEncodingASCII))
{
if
(!CFStringGetCString(pCFStringRef,results,length,kCFStringEncodingUTF8))
{
DisposePtr(results);
results = NULL;
}
}
}
return results;
}
#define kAppCFStr CFSTR("com.LogiK.XSKeyEMU")
#define kKeyCFStr CFSTR("DeviceList")
- (void) Dump_DeviceList
{
CFArrayRef prefCFArrayRef = CFPreferencesCopyAppValue(kKeyCFStr,
kAppCFStr);
CFIndex countDeviceList,index;
if (NULL == prefCFArrayRef)
return;
countDeviceList = CFArrayGetCount(prefCFArrayRef);
printf("\nThe Device list is:\n");
for (index = 0;index < countDeviceList;index++)
{
CFArrayRef pairCFArrayRef;
CFStringRef myCFString;
char* myStrPtr;
pairCFArrayRef = CFArrayGetValueAtIndex(prefCFArrayRef,index);
if (NULL == pairCFArrayRef) break;
/* 0 is name, 1 is file, 2 is serial */
myCFString = CFArrayGetValueAtIndex(pairCFArrayRef,0);
myStrPtr = Copy_CFStringRefToCString(myCFString);
// Some one gave me this.
[ populate addItemWithTitle:(NSString *)myCFString
atIndex:(int)index];
// unfortunately it doesn't work
printf("\t%ld\t\"%s\"\n",index,myStrPtr);// print list to console
DisposePtr(myStrPtr);
}
CFRelease(prefCFArrayRef);
return;
}
_______________________________________________
As previously stated, this doesn't work and I have been able to locate any
code that does work so does anyone have any working code that does this?
Dale
_______________________________________________
_______________________________________________
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.