• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Updating text fields in Cocoa.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Updating text fields in Cocoa.
      • From: amy <email@hidden>
    • Re: Updating text fields in Cocoa.
      • From: Daniel Todd Currie <email@hidden>
  • Prev by Date: Re: Adding Graphics to Buttons
  • Next by Date: Sending messages to Objective C objects at runtime
  • Previous by thread: Re: Adding Graphics to Buttons
  • Next by thread: Re: Updating text fields in Cocoa.
  • Index(es):
    • Date
    • Thread