• 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
Re: NSString problems.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString problems.


  • Subject: Re: NSString problems.
  • From: mmalcolm crawford <email@hidden>
  • Date: Wed, 11 Feb 2004 00:39:13 -0800

On Feb 11, 2004, at 12:10 AM, Daniel Todd Currie wrote:
You want:
[textField setStringValue:[NSString stringWithFormat:@"Found %@", foundDevName]];
"%@" is used to insert any object into a stringWithFormat. You can even use something like this for checking the contents of a dictionary, for example:
NSLog(@"%@", someDictionary);

Unfortunately not; although foundDevName is declared as an NSString, the assignment is:

io_name_t deviceName;
kr = IORegistryEntryGetName(usbDevice, deviceName);
printf ("%s ...\n",deviceName); // printws to console
foundDevName = (NSString *)deviceName; // need to use deviceName later

I repeat my recommendation to Dale of reviewing the basic documentation for Objective-C <http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaObjects/index.html>... It would probably also be worth revisiting a good C reference.

mmalc




On 2004 Feb 10, at 23:21, email@hidden wrote:

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.

References: 
 >NSString problems. (From: email@hidden)
 >Re: NSString problems. (From: Daniel Todd Currie <email@hidden>)

  • Prev by Date: Re: At my wits end with NSSound!
  • Next by Date: Re: Making the correct button the default button?
  • Previous by thread: Re: NSString problems.
  • Next by thread: Re: NSString problems.
  • Index(es):
    • Date
    • Thread