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

Re: NSString Question


  • Subject: Re: NSString Question
  • From: Andy Lee <email@hidden>
  • Date: Mon, 18 Aug 2008 13:22:40 -0400

You haven't mentioned whether you're deliberately avoiding NSFileHandle for some reason. Are you aware of it? It has methods to seek and read. You can get the bytes from the resulting NSData object.

On Aug 18, 2008, at 10:54 AM, Dave wrote:
[thePropertiesInfoPtr->mNameString initWithCharacters: myStringBufferPtr length:myStringSize];

It is best practice to do alloc and init at the same time, instead of doing init separately as you're doing here. Init methods may return a different object than you started with, especially if you instantiate what's called a class cluster, which NSString is.


If you split the alloc and init, you can fall into this trap:

    NSString *s = [NSString alloc];   // returns an object
    [s initWithBlahBlahBlah...];      // returns a *different* object,
                                      //   and s is actually invalid

You should do

    NSString *s = [[NSString alloc] initWithBlahBlahBlah...];

--Andy

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSString Question (From: Dave <email@hidden>)

  • Prev by Date: Re: Right place to unobserve notifications in a document
  • Next by Date: Re: NSString Question
  • Previous by thread: NSString Question
  • Next by thread: Re: NSString Question
  • Index(es):
    • Date
    • Thread