Re: NSString Question
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