What seems like a fairly straightforward concept is proving to give me an error that (unfortunately) isn't very helpful in targeting or tracking down the true source of my problem.
What I've done is defined another Object (NSObject) in a separate header file called "IM.h" from the main file I am working on. Here is the contents of that file:
Now, in the main header file that I am working on, I import the other header file and make a few other variable declarations as follows:
Code:
#import "IM.h"
@interface WebServiceTestViewController : UIViewController {
NSMutableArray *ims;
IM *currentIM;
}
@property(nonatomic, retain) NSMutableArray *ims;
@property(nonatomic, retain) IM *currentIM;
Now, in the main implementation file I want to create an array of objects. I go about it like this:
Code:
//there is a loop around this code to grab multiple records from the datasource, which is an XML feed
currentIM = [[IMalloc] init];
currentIM.firstname = firstnamevariable;
currentIM.lastname = lastnamevariable;
currentIM.email = emailvariable;
[ims addObject:currentIM];
[currentIM release];
However, when I go to build the app, I get this error message:
_OBJC_CLASS_$_IM", referenced from:
__objc_classrefs__DATA@0 in WebServiceTestViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Any help toward why I am getting this message would be super-helpful. I know I must be doing something wrong, I just can't put my finger on it...
Last edited by pumpkin8463; 05-13-2010 at 02:24 PM.
Reason: updated information in the implementation file
What seems like a fairly straightforward concept is proving to give me an error that (unfortunately) isn't very helpful in targeting or tracking down the true source of my problem.
What I've done is defined another Object (NSObject) in a separate header file called "IM.h" from the main file I am working on. Here is the contents of that file:
Now, in the main header file that I am working on, I import the other header file and make a few other variable declarations as follows:
Code:
#import "IM.h"
@interface WebServiceTestViewController : UIViewController {
NSMutableArray *ims;
IM *currentIM;
}
@property(nonatomic, retain) NSMutableArray *ims;
@property(nonatomic, retain) IM *currentIM;
Now, in the main implementation file I want to create an array of objects. However, when I go to build the app, I get this error message:
_OBJC_CLASS_$_IM", referenced from:
__objc_classrefs__DATA@0 in WebServiceTestViewController.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Any help toward why I am getting this message would be super-helpful. I know I must be doing something wrong, I just can't put my finger on it...
You're defining a class in the IM.h file, but nowhere do you have an implementation for the class. You need to implement it somewhere (IM.m would be a good place).
You're defining a class in the IM.h file, but nowhere do you have an implementation for the class. You need to implement it somewhere (IM.m would be a good place).
Thank you Kalimba. What I am looking to do is really just create a second object that I can instantiate to load into an array. Is there another way of creating a second object in the main header file rather than having to create a second header file? (this would prevent having to create another implementation file)
Alternatively, how would I go about creating a basic implementation file for this, but referenced and used in the main implementation file? If I create just a basic shell/template, should that be enough to get rid of the error?
Thank you Kalimba. What I am looking to do is really just create a second object that I can instantiate to load into an array. Is there another way of creating a second object in the main header file rather than having to create a second header file? (this would prevent having to create another implementation file)
Alternatively, how would I go about creating a basic implementation file for this, but referenced and used in the main implementation file? If I create just a basic shell/template, should that be enough to get rid of the error?
You could put the interface declaration of this new class in the "main header file", and put the new class' implementation in the main implementation file. But if you get in the habit of doing that, those files could get large and messy pretty quickly.
I would stick to putting everything about this new class into its own header and implementation files. To get what you currently have working correctly, all you need to do is add an "IM.m" file with the following code:
You could put the interface declaration of this new class in the "main header file", and put the new class' implementation in the main implementation file. But if you get in the habit of doing that, those files could get large and messy pretty quickly.
I would stick to putting everything about this new class into its own header and implementation files. To get what you currently have working correctly, all you need to do is add an "IM.m" file with the following code:
Kalimba, I'm hoping that I could ask your help for one more problem that is very related to the above thread. I managed to get my objects loaded into in array, but need a pointer in how to retrieve them -- I'm getting 3 errors stating "error: request for member 'XXX' in something not a structure or union" (where XXX is each variable that I am trying to retrieve from the object within the array).
I already walked through how I load data into the array, so I won't repeat that again.
Here is how I am trying to retrieve data from the array of objects within the main implementation file (note: I ended up creating a second header file called "ims.h" and it is included in this main implementation file:
Kalimba, I'm hoping that I could ask your help for one more problem that is very related to the above thread. I managed to get my objects loaded into in array, but need a pointer in how to retrieve them -- I'm getting 3 errors stating "error: request for member 'XXX' in something not a structure or union" (where XXX is each variable that I am trying to retrieve from the object within the array).
I already walked through how I load data into the array, so I won't repeat that again.
Here is how I am trying to retrieve data from the array of objects within the main implementation file (note: I ended up creating a second header file called "ims.h" and it is included in this main implementation file:
The trick here is that because an NSArray holds objects of generic type "id", to convince the compiler that you're doing things correctly, you need to cast "tempMessase" to the desired type before accessing the properties.
Hi,
i am an newbie in iphone and ipad devp, i saw your post and found very helpful and very easily answered....
could you help me plz..
actually this app was already made and i have to upgarde it..
the previous devp had used same class iPhone downloadfile for ipad and iphone.. but i want to make it different as its size differs in both devices... but when i copy paste the code in another file with little bit changes i get this single error.. any help will be thankful...
Undefined symbols:
"_OBJC_CLASS_$_iPad_downloadfile", referenced from:
objc-class-ref-to-iPad_downloadfile in SecondView.o
ld: symbol(s) not found
collect2: ld returned 1 exit status