Why not use -substringWithRange: ?

On 17 Apr 2011, at 21:09, JAMES ROGERS wrote:

> I know there must be a better way but this was all I could come up with as a 
> rookie cocoa programmer to get a substring out of a  very long NSString from 
> a textView growing as the operator types in the message content. The receive 
> buffer in the chip I am talking to will only take 80 characters before an 
> XOFF (buffer 2/3 full).  XON occurs when the chip buffer is reduced to about 
> 1/3 full.  This routine is in a thread that reads data from the chip as well.
> 
> char sndBuffer[65];
> int j;
> 
> characterIndex++;  // is always sitting at the last character sent so advance 
> to the next character in string.
> for (j = 0; j < 65; j++) {
>    sndBuffer[j] = [string characterAtIndex:characterIndex];
>    characterIndex++;
> }
> sndBuffer[j] = 0x00;
> substring = [NSString stringWithUTF8String:sndBuffer];
> 
> It works flawlessly, but there oughta be a way without reverting to C?
> Suggestions very much welcomed.
> 
> JIM ROGERS
> jimrogers_w4...@me.com
> http://web.me.com/jimrogers_w4atk
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please 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:
> http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net
> 
> This email sent to cocoa...@mikeabdullah.net

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to