getCString a good idea here?
getCString a good idea here?
- Subject: getCString a good idea here?
- From: Michael Hanna <email@hidden>
- Date: Sat, 12 Jul 2003 18:30:31 -0400
Hi I'm trying to output to the stdout with a foundation tool. But it
seems I'm not using getCString improperly.. I'm certain that the array
returns an NSString. phrase_01 is an NSArray:
code snippet 1 of 2: the method randPhrase:
#import <Foundation/Foundation.h>
#import <stdlib.h>
#import <time.h>
unsigned randPhrase(int length) {
return (int)(random() % length);
}// randPhrase
...
code snippet 2 of 2: the offending line of code:
...
srandom( (unsigned int) time(NULL)); // generate a seed value
NSLog ( @"phrase_01 = %@", phrase_01);
printf("I met her %s %s\n",
[[phrase_01 objectAtIndex: randPhrase( [phrase_01 count] ) ]
getCString],
[phrase_02 objectAtIndex: randPhrase( [phrase_02 count] ) ]);
...
OUTPUT --
2003-07-12 18:24:34.547 countrysong[25224] phrase_01 = <CFArray 0x59ab0
[0xa01303fc]>{type = immutable, count = 11, values = (
0 : on the highway
1 : in Sheboygan
2 : outside Fresno
3 : at a truck stop
4 : on probation
5 : in a jail cell
6 : in a nightmare
7 : incognito
8 : in the Stone Age
9 : in a treehouse
10 : in a gay bar
)}
2003-07-12 18:24:34.769 countrysong[25224] *** -[NSConstantString
getCString]: selector not recognized
2003-07-12 18:24:34.770 countrysong[25224] *** Uncaught exception:
<NSInvalidArgumentException> *** -[NSConstantString getCString]:
selector not recognized
countrysong has exited due to signal 5 (SIGTRAP).
regards,
Michael
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.