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

NSString "midstring()"


  • Subject: NSString "midstring()"
  • From: JAMES ROGERS <email@hidden>
  • Date: Sun, 17 Apr 2011 15:09:31 -0500

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

  • Follow-Ups:
    • Re: NSString "midstring()"
      • From: Quincey Morris <email@hidden>
    • Re: NSString "midstring()"
      • From: Mike Abdullah <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: Re: How do I disable Xcode 4's SVN support?
  • Next by thread: Re: NSString "midstring()"
  • Index(es):
    • Date
    • Thread