Updating text fields in Cocoa.
Updating text fields in Cocoa.
- Subject: Updating text fields in Cocoa.
- From: email@hidden
- Date: Sun, 1 Feb 2004 02:52:36 EST
Slowly making progress by trial and error, here is the code, the two
commented out routines are what doesn't work.
From Foo.h I have the following.
#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>
#import <stdio.h>
@interface Preferences : NSObject
{
IBOutlet id _XSKeyEMU;
IBOutlet id enableKey;
IBOutlet id enableStart;
IBOutlet id prefWindow;
IBOutlet id showActive;
IBOutlet id showSerial;
NSUserDefaults *pref;
CFStringRef appID;
}
- (IBAction)apply:(id)sender;
- (IBAction)prefClose:(id)sender;
- (void)open;
- (void)updateWindow;
- (void)savePrefs;
- (BOOL)windowShouldClose:(id)sender;
@end
From Foo.m I have this semi functional routine.
static void Dump_DeviceList(void)
{
CFArrayRef prefCFArrayRef = CFPreferencesCopyAppValue(kKeyCFStr,
kAppCFStr);
CFIndex countDeviceList,index,selected;
if (NULL == prefCFArrayRef)
return;
countDeviceList = CFArrayGetCount(prefCFArrayRef);
printf("\nThe Device list is:");
for (index = 0;index < countDeviceList;index++)
{
CFArrayRef pairCFArrayRef;
CFStringRef DevNameCFString;
char* DevNameStrPtr;
CFStringRef FileNameCFString;
char* FileNameStrPtr;
CFStringRef SerialCFString;
char* SerialStrPtr;
pairCFArrayRef = CFArrayGetValueAtIndex(prefCFArrayRef,index);
if (NULL == pairCFArrayRef) break;
DevNameCFString = CFArrayGetValueAtIndex(pairCFArrayRef,0);
DevNameStrPtr = Copy_CFStringRefToCString(DevNameCFString);
FileNameCFString = CFArrayGetValueAtIndex(pairCFArrayRef,1);
FileNameStrPtr = Copy_CFStringRefToCString(FileNameCFString);
SerialCFString = CFArrayGetValueAtIndex(pairCFArrayRef,2);
SerialStrPtr = Copy_CFStringRefToCString(SerialCFString);
printf("\n\t%ld\t\"%s\"\t\"%s\"\t\"%s\""
,index,DevNameStrPtr,FileNameStrPtr,SerialStrPtr);
selected = 0; //hard code selected match for now.
if (index == selected)
{
// [showActive setStringValue: @FileNameStrPtr]; //this doesn't
work
// [showSerial setStringValue: @SerialStrPtr]; //this doesn't work
}
DisposePtr(DevNameStrPtr);
DisposePtr(FileNameStrPtr);
DisposePtr(SerialStrPtr);
}
CFRelease(prefCFArrayRef);
return 0;
}
--------------------------------------------
Anyone have code will work in this location as I have read a lot and can't
figure it out and haven't seen any code that works from any sample code I have.
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.