Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

PaperFace

macrumors newbie
Original poster
Sep 18, 2008
8
0
Heya, my first post here. I've been trying my hardest to write an iPhone app and while I've made good progress, I've hit a stumbling block on something which seems simple enough, but just refuses to work.

I'm writing a simple 'terminal' application to connect to a server, send data, display data, figured that'd be a good starting block.

At the moment all the data coming in gets inserted into a NSMutableArray, I figured this way I could limit the history to say 100 packets worth of data rather than just appending it all into a single string which would be hard to tidy up.

The problem i'm having is displaying the entire contents of the array in a textview. By default I have two objects in the array to test it with.

This works fine, and I can change the index to 0 and 1 and it still works..
Code:
 NSMutableString *tmp = [[[NSMutableString alloc] init] autorelease];
 tmp = [rawData objectAtIndex:0];
textView.text = tmp;

But this falls on it's arse and causes an uncaught exception..

Code:
	 NSMutableString *tmp = [[[NSMutableString alloc] init] autorelease];

	 int count = [rawData count];
	 int i = 0;
	 while (i < count)
	 {
		 [tmp appendString:[[rawData objectAtIndex:i] stringValue]];
		 i++;
	 }

	 textView.text = tmp;

I've scoured the net for days over this silly little problem, and can't find any examples other than ones which do it how I am doing it.

Any suggestions?

Thanks in advance.
 

PaperFace

macrumors newbie
Original poster
Sep 18, 2008
8
0
Sorry, totally new to mac coding and xcode. Let me see if I can find and paste it.

Code:
2008-09-18 11:28:20.783 iTerminal[1160:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFString stringValue]: unrecognized selector sent to instance 0x47c2b0'

Oh and incase your wondering how I'm populating the array..

Code:
//read data
uint8_t buffer[1024];
int len;
while ([_inStream hasBytesAvailable])
{
	len = [_inStream read:buffer maxLength:sizeof(buffer)];
	if (len > 0)
	{
		NSString *output = [[NSString alloc] initWithBytes:buffer length:len encoding:NSASCIIStringEncoding];

		if (nil != output)
		{
			NSLog(@"%@", output);
			[_raw addObject:output];
			[output release];
		}
	}
}
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Well the exception is very clear. I'm not sure what more I can say. It tells you that you are sending an instance of NSString the message stringValue and that this NSString does not respond to this selector.

If we look at the NSString documentation we see that, indeed, NSString does not support stringValue. Stop sending NSStrings stringValue messages!
 

PaperFace

macrumors newbie
Original poster
Sep 18, 2008
8
0
Thanks,

man, trust the answer to be as obvious as that. Never realized xcode had a more in-depth error log until you asked.

Cheers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.