i'm doing work using redpark serial cable ios. cable allows serial communication between ios device , device microcontroller.
there method comes redpark sdk reads bytes available on serial line. method called anytime cable receives informatino.
(void)readdatabytes(uint32 bytes) { nsstring *s = [[nsstring alloc] initwith...bytes]; nsstring *editedstring = [self extractsubstringmethod:s]; [myarray addobject:editedstring]; } the microcontroller sending information in following format
<msg>xxxxxxxxxxxxx</msg> i want able extract x's message (which taken in nsstring). @ moment i'm using nsrange extract after position 4 (the first x) , before final "< /msg>" i'm not convinced works , wondering there other ideas?
finally, have nsthread running alongside this, have messages being added nsmutablearray. want is, nsthread manipulating/displaying message information when there message received cable. have following
//thread method, while([myarray count] > 0) //don't believe neccesary in anyway { for(int = 0; < [myarray count]; i++){ nsstring *string = [myarray objectat(i)]; [self displaystring:string]; [myarray removeobjectat(i); } } i believe it's crashing around above... [self displaystring:string] sets value of label,
-(void)displaystring(nsstring *string) { label.text = [string charat(1)]; } the code above memory i've left mac @ home , i'm in work. suggestions/help appreciated
instead of
while([myarray count] > 0) //don't believe neccesary in anyway { for(int = 0; < [myarray count]; i++){ nsstring *string = [myarray objectat(i)]; [self displaystring:string]; [myarray removeobjectat(i); } } try this:
while ([myarray count] > 0) { [self displaystring: myarray[0]]; [myarray removeobjectatindex: 0]; }
Comments
Post a Comment