• 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: NSString "midstring()"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString "midstring()"


  • Subject: Re: NSString "midstring()"
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 17 Apr 2011 21:22:55 +0100

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
> email@hidden
> http://web.me.com/jimrogers_w4atk
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSString "midstring()"
      • From: JAMES ROGERS <email@hidden>
References: 
 >NSString "midstring()" (From: JAMES ROGERS <email@hidden>)

  • Prev by Date: Re: Proper way to create a singleton without @synchronized ?
  • Next by Date: Re: Proper way to create a singleton without @synchronized ?
  • Previous by thread: NSString "midstring()"
  • Next by thread: Re: NSString "midstring()"
  • Index(es):
    • Date
    • Thread