• 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: very simple NSRange q
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: very simple NSRange q


  • Subject: Re: very simple NSRange q
  • From: Marc Weil <email@hidden>
  • Date: Mon, 11 Aug 2003 10:13:57 -0400

The reason the first one works is because you are initializing the variable
with the declaration. Basically, you are using an old C trick to do it.

You should be using NSMakeRange() for both cases, since that will guarantee
you that the range is created properly. There are a whole bunch of
range-manipulation functions that are at your disposal, so you can do very
interesting things with them.

http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_cla
ssic/Functions/FoundationFunctions.html#//apple_ref/doc/uid/20000055/BCIDFCG
F

- Marc Weil


On 8/11/03 9:55 AM, "Ben Dougall" <email@hidden> wrote:

> hiyer,
>
> i used NSRange like this with no problems just recently:
>
> NSRange range = {startofinfo, endofinfo-startofinfo+1};
> NSData *tempdata;
> tempdata = [pdfData subdataWithRange:range];
>
>
> but now, in a separate situation, i'm trying to use them in a slightly
> different way but it's not happening.
>
> in the object's @interface variable section:
>
> NSRange data;
>
> and in the object's init method:
>
> 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?
>
> thanks, ben.
> _______________________________________________
> 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.
_______________________________________________
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: 
 >very simple NSRange q (From: Ben Dougall <email@hidden>)

  • Prev by Date: Re: GCC3?
  • Next by Date: Re: very simple NSRange q
  • Previous by thread: very simple NSRange q
  • Next by thread: Re: very simple NSRange q
  • Index(es):
    • Date
    • Thread