Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-13-2010, 01:57 PM   #1 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 6
pumpkin8463 is on a distinguished road
Default Object Referencing Error: Symbol(s) not found

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:

Code:
@interface IM : NSObject {
	NSString *firstname;
	NSString *lastname;
	NSString *email;
}

@property(nonatomic, retain) NSString *firstname;
@property(nonatomic, retain) NSString *lastname;
@property(nonatomic, retain) NSString *email;

@end
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
pumpkin8463 is offline   Reply With Quote
Old 05-13-2010, 02:03 PM   #2 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

Quote:
Originally Posted by pumpkin8463 View Post
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:

Code:
@interface IM : NSObject {
	NSString *firstname;
	NSString *lastname;
	NSString *email;
}

@property(nonatomic, retain) NSString *firstname;
@property(nonatomic, retain) NSString *lastname;
@property(nonatomic, retain) NSString *email;

@end
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).
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 05-13-2010, 03:47 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 6
pumpkin8463 is on a distinguished road
Default

Quote:
Originally Posted by Kalimba View Post
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?
pumpkin8463 is offline   Reply With Quote
Old 05-13-2010, 05:59 PM   #4 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

Quote:
Originally Posted by pumpkin8463 View Post
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:
Code:
#import "IM.h"

@implementation IM

@synthesize firstname;
@synthesize lastname;
@synthesize email;

@end
I'm pretty sure that'll do it.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 05-13-2010, 08:35 PM   #5 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 6
pumpkin8463 is on a distinguished road
Default

Quote:
Originally Posted by Kalimba View Post
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:
Code:
#import "IM.h"

@implementation IM

@synthesize firstname;
@synthesize lastname;
@synthesize email;

@end
I'm pretty sure that'll do it.
Thanks a ton Kalimba! That did it!
pumpkin8463 is offline   Reply With Quote
Old 05-13-2010, 10:43 PM   #6 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 6
pumpkin8463 is on a distinguished road
Default Getting data out of the array of objects :S

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:

Code:
for (int i=0; i=[ims count]; i++)
{
	NSMutableArray *tempMessage = [[NSMutableArray arrayWithObject:[ims objectAtIndex:i]] retain];
	NSMutableString *cumulativeText = [[NSMutableString stringWithFormat:@"%@\n\n%@ %@: %@", cumulativeText, tempMessage.firstname, tempMessage.lastname, tempMessage.email] retain];
}
Again, I hope it's a simple oversight and nothing too complex I'm missing here.
pumpkin8463 is offline   Reply With Quote
Old 05-14-2010, 08:51 AM   #7 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 2,176
Kalimba is on a distinguished road
Default

Quote:
Originally Posted by pumpkin8463 View Post
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:

Code:
for (int i=0; i=[ims count]; i++)
{
	NSMutableArray *tempMessage = [[NSMutableArray arrayWithObject:[ims objectAtIndex:i]] retain];
	NSMutableString *cumulativeText = [[NSMutableString stringWithFormat:@"%@\n\n%@ %@: %@", cumulativeText, tempMessage.firstname, tempMessage.lastname, tempMessage.email] retain];
}
Again, I hope it's a simple oversight and nothing too complex I'm missing here.
Looking at that code, I believe you really want "tempMessage" to be an instance of your IM class. So, try this:
Code:
for (int i=0; i=[ims count]; i++)
{
	IM *tempMessage = (IM *)[ims objectAtIndex:i];
	NSMutableString *cumulativeText = [NSMutableString stringWithFormat:@"%@ %@: %@", tempMessage.firstname, tempMessage.lastname, tempMessage.email];
	NSLog( cumulativeText );
}
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.
__________________
~~ Word Flurry ~~ App Store / Website / Facebook
Kalimba is offline   Reply With Quote
Old 09-22-2011, 03:04 AM   #8 (permalink)
Registered Member
 
Join Date: Sep 2011
Location: Pune
Posts: 3
Mayank Mathur is on a distinguished road
Default a samll help from you Kalimba

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...

waiting for your reply soon



Ld build/iphoneDistribution-iphonesimulator/publication.app/publication normal i386
cd /Users/shailesh/Desktop/NewPublication
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/shailesh/Desktop/NewPublication/build/iphoneDistribution-iphonesimulator -F/Users/shailesh/Desktop/NewPublication/build/iphoneDistribution-iphonesimulator -filelist /Users/shailesh/Desktop/NewPublication/build/publication.build/iphoneDistribution-iphonesimulator/publication.build/Objects-normal/i386/publication.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -lz.1.2.3 -lxml2 -framework SystemConfiguration -o /Users/shailesh/Desktop/NewPublication/build/iphoneDistribution-iphonesimulator/publication.app/publication

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
Mayank Mathur is offline   Reply With Quote
Reply

Bookmarks

Tags
collect2, error, object, status, symbol

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 311
11 members and 300 guests
Abidullah, ajay123123, Fstuff, guusleijsten, HemiMG, jbro, n00b, newDev, pkIDSF, Sami Gh, Steven.C
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0