Re: very simple NSRange q
Re: very simple NSRange q
- Subject: Re: very simple NSRange q
- From: "Alastair J.Houghton" <email@hidden>
- Date: Mon, 11 Aug 2003 15:13:59 +0100
On Monday, August 11, 2003, at 02:55 pm, Ben Dougall wrote:
data = {start, length};
and i get lot's of errors:
TempStreamObj.m:20: illegal expression, found `{'
TempStreamObj.m:20: illegal statement, missing `;' after `length'
TempStreamObj.m:22: illegal external declaration, found `return'
TempStreamObj.m:20: parse error before '{' token
how should initiate this range? also why is the first one working and
the second one not?
Use NSMakeRange(). The second one doesn't work because it isn't legal
to write an initialiser (which is what {start, length} is) in code,
only in a declaration. You *can* work around this with GCC by writing
(NSRange){start, length}, but it's a non-standard extension. Better to
use the helpfully provided NSMakeRange() function. BTW, there are
similar functions for many of the other struct types.
Kind regards,
Aalastiar.
_______________________________________________
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.