Re: NSRange help
Re: NSRange help
- Subject: Re: NSRange help
- From: Andy Lee <email@hidden>
- Date: Mon, 1 Apr 2002 19:45:55 -0500
At 6:21 PM -0600 4/1/02, Jason Moore wrote:
Can anyone help me with using an NSRange? I have a for loop in which
i'm trying to pick out certain chunks of data from an NSData object
using GetBytes:range:. I have two variables with which i'd like to
create a range (both unsigned int). However, i can't seem to get the
range working correctly.
I've tried:
NSRange range;
for (...)
{
if (condition1)
range = NSMakeRange(var1,var2);
else
range = NSMakeRange(var3, var4);
etc..
}
and a few variations on that theme, but nothing seems to work.
The NSRange code looks reasonable to me. I suspect the culprit is
elsewhere. What do you mean by "nothing seems to work"??? Maybe you
could post a bit of your actual code -- in particular, the call to
-getBytes:range: and the lines surrounding it. What are you passing
as the buffer argument to -getBytes:range:? Have you tried
sprinkling your code with NSLogs to make sure the NSData contains
what you think it contains? How about using NSLogs to print the
values of var1..var4 above to make sure you are plugging in the
values you think you are plugging in?
When i try and print a range variable in an NSLog it comes back as NULL.
NSRange is a struct, so I'm not sure what you mean by it coming back
as NULL unless you've mistakenly assumed it was an object or a
pointer. What does your NSLog statement look like? An example that
should work would be:
NSLog(@"location: %d, size: %d", myRange.location, myRange.size);
--Andy
_______________________________________________
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: | |
| >NSRange help (From: Jason Moore <email@hidden>) |