![]() |
n00b obj-c question @property
hi, the following is my code (three sep. files). i'm getting an error stating that i have a parsing error before the '@' symbol. i'm just trying to wrap my head around all this and i can't find my mistake (copying from a book for now). :|
please help! thx! :)
|
I didn't see any problem with your code. It built and ran first time on XCode 3.1.1
Code:
2009-03-25 21:11:42.137 Fractions[2525:10b] 1/4 |
What's the name of the third file (containing main())? Make sure it has a .m extension or the compiler will assume C instead of Objective-C, where an @ will probably cause errors.
|
hey everyone,
thanks for looking the code over. unfortunately, it's not compiling for me! :| does it matter that i'm using xCode 2.5? i'm not on an intel-based mac. :eek: i checked the file extensions. xyz.m so it _should_ be picking up correctly. i even tried putting all the data into one file (so no import other htan an #import <Foundation/Foundation.h>)... erg. |
Hi M
Yes. I think you'll need XCode 3 to compile that code. And I think you have to use Leopard to run that. However I believe XCode 3 does run on PPC. I think the @property syntax isn't available on the ObjC on 2.5 - although it's easy to work around that. Let me know if you're stuck and I'll fix it this evening for you after work. Robin |
for some reason i was under the impression that xcode 3.x wouldn't run on ppc mac's...is that only the iphone sdk (that won't run on a ppc mac)?
thanks for your help thus far! :) |
Quote:
messels: First, you didn't actually say what line the error happened on. That is important information. Second, at this point it would probably be easiest if you zipped up a copy of your project folder and posted it here for us to attempt to build. We cannot reproduce your problem, so it's probably project-specific. |
I've zipped the code to build and run on on XCode 2.5 on my elderly PPC Powerbook running Tiger 10.4.11 and on XCode 3 on my super-dooper x86 iMac running Leopard:
http://clanmills.com/files/messels.zip You'll find two directories: Fractions2 - for XCode 2.5 Fractions3 - for XCode 3 Please see ReadMe.txt with a little discussion about the @property and @synthesize keywords. Hope that helps. Robin |
Quote:
hey robin, it certainly is a big help. thanks! what i don't understand is that you're not actually using the @property or @synthesize in the fraction classes for xCode 2.x, forcing you to create the getters and setters, right? you also used the cocoa (#import <Cocoa/Cocoa.h>) whereas i was under the impression that i was suppose to change that to <Foundation/Foundation.h>. why did you use cocoa and the book suggests foudnation? is that becuase you're working in xcode 2.5 and need to use cocoa in that instance or is it that the libraries in foundation are also present in cocoa? thanks again! :D |
Quote:
He's #importing and linking to Cocoa needlessly. The project only needs Foundation. |
|
Quote:
|
Mikey-San
I respect your many and very wise contributions to this forum. I promise to report back to this thread when we have reached a positive conclusion. Robin |
Quote:
|
Mikey-San
Please forgive me. 100% apology to you. Robin |
Mike-san is quite correct. It isn't productive to discuss things off-line.
To answer messels question about Cocoa/Cocoa.h and Foundation/Foundation.h. I quite unaware of this. I used the wizard to create a project from which to call his code. The wizard wrote that code. I believe Mike-san's correct that @property feature was added to Obj-C some time ago. None-the-less messel's code does not compile on 2.5. I got the same error message about the '@'. Something interesting to investigate here. I'll report back. I'd like to challenge to messels. Why is the result wrong? 1/2 + 1/4 = 6/8. When I was in elementary school in Scotland, 1/2+1/4=3/4. |
Quote:
|
The release notes for Xcode 3.0 (http://developer.apple.com/releaseno...ode/index.html) say:
Quote:
|
Quote:
|
Quote:
Are you saying that you are mistaken and @property was not supported with XCode 2.5 ? |
Well, it looks that way. Does changing the compiler affect the target's ability to build? If not, there's your answer.
|
I believe that XCode is a UI which uses gcc and gdb to do the heavy lifting. So it's possible that when you install XCode 2.5 and 3.x on the same machine, they both use the same gcc and gdb. If the error message about '@' is coming from gcc (which I believe is the case), XCode 2.5 may be able to successfully build the project when both are installed. However on a "pure" XCode 2.5, it cannot. I said there was something interesting to investigate here. Goodness that's not obvious.
|
Quote:
anyway, sounds like i need to update to leopard at least...so i can just learn the latest version and not worry so much about what's been enhanced and what's not. i just want to learn this stuff. thx' |
Quote:
|
Indeed I get a segmentation fault when I try to execute the Leopard build of Fractions.app on Tiger. The original issue is the compiler's error message which is due to @property not being supported in 2.5. So for both the compiler and the runtime, Tiger and @property don't live happily together.
It's a little odd that XCode 2.5 can build @property on Leopard when 3.0 has also been installed. And for sure you need the Leopard run-time system to execute it. So I think we've beaten this one to death. M's thoughts to update to Leopard seem like a good idea I wish him every success in learning Cocoa. A journey worth the effort. |
Quote:
|
Quote:
However I don't think it really matters much whether this statement is true or not. Compiling @property on 2.5 doesn't really get anybody anywhere. As you have pointed out they still need Leopard to execute the code. So I think that is the conclusion - we're encouraging M to upgrade to Leopard and XCode 3.:) |
Quote:
|
| All times are GMT -5. The time now is 05:36 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.