Re: NSString problems.
Re: NSString problems.
- Subject: Re: NSString problems.
- From: Yann Bizeul <email@hidden>
- Date: Wed, 11 Feb 2004 09:29:47 +0100
It seem you are not retaining your NSString. Since you seem to use it
outside of the current event loop, you need to retain it to make it
persistent, or it will be auto-freed.
I would try something like that :
foundDevName = [ (NSString *)deviceName retain ]; // need to
use deviceName later
Don't forget to release it when you need to reassign a value.
Le 11 fivr. 04, ` 08:21, email@hidden a icrit :
After reading all about NSStrings I thought this would work however it
give
eroneous characters with the setStringValue in doFind and it's not
clear to me
what the problem is.
code:
_______________________________________________
static CFStringRef deviceNameAsCFString;
static NSString *foundDevName;
_______________________________________________
void DeviceAdded(void *refCon, io_iterator_t iterator)
{
kern_return_t kr;
io_service_t usbDevice;
IOCFPlugInInterface **plugInInterface=NULL;
SInt32 score;
HRESULT res;
while (usbDevice = IOIteratorNext(iterator))
{
io_name_t deviceName;
// Get the USB device's name.
kr = IORegistryEntryGetName(usbDevice, deviceName);
printf ("%s ...\n",deviceName); // printws to console
foundDevName = (NSString *)deviceName; // need to use
deviceName later
}
return;
}
- (IBAction)doFind:(id)sender
{
[textField setStringValue: @"Looking for devices"];
if (isDevicePresent)
{
[actionButton setTitle:@"Dump Device"];
[actionButton setAction:@selector(doDump:)];
[textField setStringValue:[NSString stringWithFormat:@"Found
%s",
foundDevName]]; // ???????
}
else
{
[textField setStringValue: @"Couldn't Find Device"];
}
return;
}
_______________________________________________
What did I miss????
Mr. Dale Walsh
_______________________________________________
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.
--
Yann Bizeul - yann at tynsoe.org
http://projects.tynsoe.org/
_______________________________________________
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.