I am brand new to Objective-C programming and teaching myself using Objective-C for absolute beginners (which demonstrates and earlier version of Xcode and working on Xcode 4.3.3 (probably part of the problem) and various sources on the web. I have become stuck on an exercise where I am getting the exception(lldb) and have no idea where I am going wrong. I get a build succeed then the error.
code as follows:
[#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSMutableArray *bookList = [NSArray arrayWithObjects:@"Moby Dick",@"Frankenstein", @"Tom Sawyer",nil];
int count;
count= bookList.count;
for (int y=0;y<count;y++)
{
NSLog(@"Book Title is %@", [bookList objectAtIndex:y]);
[bookList addObject:(@"Huckleberry Finn")];
}
return 0;
}}
]
and the console reads:
[2012-08-21 15:37:56.445 Comparison[1142:403] Book Title is Moby Dick
2012-08-21 15:37:56.448 Comparison[1142:403] -[__NSArrayI addObject:]: unrecognized selector sent to instance 0x106d14580
2012-08-21 15:37:56.449 Comparison[1142:403] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance 0x106d14580'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff86449f56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff89951d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff864d61be -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff86436e23 ___forwarding___ + 371
4 CoreFoundation 0x00007fff86436c38 _CF_forwarding_prep_0 + 232
5 Comparison 0x0000000106c36e3a main + 266
6 Comparison 0x0000000106c36d24 start + 52
)
terminate called throwing an exception(lldb)
]
again apologies for the very simplistic problem - any guidance will be greatly appreciated..
Elro
This post has been edited by jimblumberg: 21 August 2012 - 06:49 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.

New Topic/Question
Reply


MultiQuote




|