• 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: NetSocket and parse line by line
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NetSocket and parse line by line


  • Subject: Re: NetSocket and parse line by line
  • From: "Philip Q" <email@hidden>
  • Date: Thu, 23 Nov 2006 13:08:04 +1300

On 23/11/06, Hell's KItchen Hell's KItchen <email@hidden> wrote:
        [_string appendString:str];
        start = stop = cont = 0;
        do {
            range.location = stop;
            range.length = 0;
            [_string getLineStart:&start end:&stop contentsEnd:&cont
forRange:range];

                        int len = cont-start;
            if(stop != cont && cont-start >= 0) {
                range.location = start;
                range.length = cont - start;
                                [self _fetchRawData: [_string substringWithRange:range]];
            } else {

                        }
        }
        while(stop != cont);


You seem to be using an awfully complicated way to get a single line,
and send it to your _fetchRawData: method (at least, I think that's
what you're doing).

Might I suggest that if you know that _string is only going to contain
data since the last newline (check the appropriate spec to find out
what that is), you only need to see if the newly appended string
contains that sequence, and if so, extact that range.

For example:
[_string appendString:str];
range = [_string rangeOfString:@"\r\n"] // or whatever
if (range.location != NSNotFound) {
   line = [_string substringWithRange:range];
   [_string deleteCharactersInRange:range];
   [_self fetchRawData:line];
}

You'll want to check to see if rangeOfString: includes the sequence
you're looking for in it's NSRange and modify it appropriately.
I don't have any experience with the IRC protocol, so this might be
totally useless if you were doing all that for a reason.

-Phil
_______________________________________________

Cocoa-dev mailing list      (email@hidden)

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


  • Follow-Ups:
    • Re: Re: NetSocket and parse line by line
      • From: "Hell's KItchen Hell's KItchen" <email@hidden>
References: 
 >NetSocket and parse line by line (From: "Hell's KItchen Hell's KItchen" <email@hidden>)

  • Prev by Date: Re: Custom Cocoa Views in Interface Builder
  • Next by Date: Caching variables in ManagedObjects
  • Previous by thread: Re: NetSocket and parse line by line
  • Next by thread: Re: Re: NetSocket and parse line by line
  • Index(es):
    • Date
    • Thread