• 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: Simple C Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple C Question


  • Subject: Re: Simple C Question
  • From: Ondra Cada <email@hidden>
  • Date: Thu, 31 Jan 2002 16:17:28 +0100

Nathan,

>>>>>> Nathan Day (ND) wrote at Fri, 1 Feb 2002 00:29:00 +1030:
ND> No I think he means [[NSString alloc] initWithFormat:@"%c", 'c' ]

It's possible. In that case I would personally prefer (presuming a char
variable instead of constant)

s=[[NSString alloc] initWithData:[NSData dataWithBytes:&c length:1] encoding:XXX];

though. The difference would be grave for char values over 128, and this way
you can control (by using the desired encoding for XXX) how it will behave.

Inicdentally, somewhat unrelated -- unless you would retain the thing
immediately otherwise, don't forget to autorelease objects made by alloc/init
lest they leak. The generally best pattern is to use autorelease
immediately, this way:

s=[[[NSString alloc] initWithWhatever....] autorelease]
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.cz
private email@hidden http://www.ocs.cz/oc


  • Prev by Date: Link Cocoa application to CFM library
  • Next by Date: Re: System contextual menus
  • Previous by thread: Re: Simple C Question
  • Next by thread: Re: Getting a file's icon > 32x32 (Solved)
  • Index(es):
    • Date
    • Thread