views:

362

answers:

1

I'm trying to find a the new line and returns that are inside a nsdata object that I'm parsing . Here's some code:

    uint8_t *arr = [receivedData bytes];
    NSUInteger begin1 = 0;
    NSUInteger end1 = len;
    uint8_t *arr1 = (Byte *)malloc(sizeof(Byte)*((end1-begin1+1)));
    int j = 0;
    for (int i = begin1; i < end1; i++){
     arr1[j] = arr[i];
     j++;
     if (arr[i] == 10) NSLog(@"---new line code---");  /////doesn't work
    }

I just need to know when I hit a new line or return.

Thank You.

+2  A: 

That certainly looks correct. Are you certain that the data you're parsing has newlines? Could it be a /r instead of a /n? If you can, try using the debugger and step through to see what the values actually are, and compare with what you expect them to be, to make sure they are correct.

Ed Marty
Yes, it was a fluke with the data I had, it's working now.
Bryan Cimo