 |
|
| Computers Forum Index » Computer Languages (Objective-C) » [newbie] tutorial / version of XCode..... |
|
Page 1 of 1 |
|
| Author |
Message |
| yitzhak in eretz (sic)... |
Posted: Mon Sep 14, 2009 1:37 am |
|
|
|
Guest
|
Why does Apple seem to change its XCode interface with each release of Mac
OS-X?
I'm slowly but surely (as a hobby) learning Objective-C, and was using
'Become an XCoder' but got stuck as XCode under Tiger didn't look anything
like the examples in the book. Then I updated to 10.6 and decided to go at
it again. I found this little tutorial..
<http://www.youtube.com/watch?v=y2MSvZT3zWU>
Right at 1:25 minutes, when the author adds a class action to the button,
he does so in the Inspector, but this option isn't visible in XCode 3.2.
Fine, I eventually found it in the Library palette, but then at 1:44
minutes when the author ^ drags a line from the button object to the
controller and gets a pop-up menu? I don't get that menu. How do I tell
the button to sendBeep: to BeepController?
As an aside, something's been gnawing at my mind: why, in every tutorial,
does everyone create an object to do what he wants to do? Why not just use
NSObject? Or does NSObject not lend itself to be used by a programmer?
Your help would be gratefully received.
--
Yitzhak Isaac Goldstein
AADP's 'left-wing Israeli intellectual'
'Only two things are infinite, the universe and human stupidity -
and I'm not sure about the former' ((Albert Einstein) |
|
|
| Back to top |
|
|
|
| Pascal J. Bourguignon... |
Posted: Mon Sep 14, 2009 1:59 am |
|
|
|
Guest
|
"yitzhak in eretz (sic)" <yitzhak at (no spam) yahoo.com> writes:
Quote: As an aside, something's been gnawing at my mind: why, in every tutorial,
does everyone create an object to do what he wants to do? Why not just use
NSObject? Or does NSObject not lend itself to be used by a programmer?
Your help would be gratefully received.
A farmer notices his chickens are getting sick, he calls in a
physicist to help him. The physicist takes a good look at the
chuckens and does some calculations, he suddenly stops and says
"I've got it, but it would only work if the chickens were
spherical and in a void.".
Any method you would add to NSObject would be available to any object,
of any class. If you added a method -fly, suddenly all your
Elephants, Boxes, Cars, Books, Operations, whatever you have in your
program, would be able to fly.
Worse, if you want to merge the features implemented by different
programmers in a single application, if methods have been added to
common classes, they might clash (if they have the same selector).
Doing that you would lose all the benefit of Object Orientation,
namely encapsulation.
NSObject, and any other framework class, is a global resource, a
global namespace. If you define something here, you will get
collision with other people's code.
--
__Pascal Bourguignon__ |
|
|
| Back to top |
|
|
|
| yitzhak in eretz (sic)... |
Posted: Mon Sep 14, 2009 2:28 am |
|
|
|
Guest
|
On 2009-09-13, Pascal J. Bourguignon <pjb at (no spam) informatimago.com> wrote:
Quote: "yitzhak in eretz (sic)" <yitzhak at (no spam) yahoo.com> writes:
As an aside, something's been gnawing at my mind: why, in every tutorial,
does everyone create an object to do what he wants to do? Why not just use
NSObject? Or does NSObject not lend itself to be used by a programmer?
Your help would be gratefully received.
A farmer notices his chickens are getting sick, he calls in a
physicist to help him. The physicist takes a good look at the
chuckens and does some calculations, he suddenly stops and says
"I've got it, but it would only work if the chickens were
spherical and in a void.".
Any method you would add to NSObject would be available to any object,
of any class. If you added a method -fly, suddenly all your
Elephants, Boxes, Cars, Books, Operations, whatever you have in your
program, would be able to fly.
Worse, if you want to merge the features implemented by different
programmers in a single application, if methods have been added to
common classes, they might clash (if they have the same selector).
Doing that you would lose all the benefit of Object Orientation,
namely encapsulation.
NSObject, and any other framework class, is a global resource, a
global namespace. If you define something here, you will get
collision with other people's code.
Clear and comprehensible. Thank you.
Y.
--
Yitzhak Isaac Goldstein
'Only two things are infinite, the universe and human stupidity -
and I'm not sure about the former' ((Albert Einstein) |
|
|
| Back to top |
|
|
|
| Charlton Wilbur... |
Posted: Mon Sep 14, 2009 7:02 am |
|
|
|
Guest
|
Quote: "y" == yitzhak in eretz (sic) <yitzhak at (no spam) yahoo.com> writes:
y> On 2009-09-13, Pascal J. Bourguignon <pjb at (no spam) informatimago.com> wrote:
Quote: NSObject, and any other framework class, is a global resource, a
global namespace. If you define something here, you will get
collision with other people's code.
y> Clear and comprehensible. Thank you.
At the same time, this is precisely what categories are for.
Mr Bourguignon overstates the case slightly: if you define something in
NSObject namespace (or in the namespace of other objects close to the
root of the inheritance tree like NSNumber), you are *very likely* to
get collisions with other people's code. However, this is not to say
that it shouldn't be done, but that it shouldn't be done without a very
good reason and without understanding the ramifications.
It's rather like the rules on code optimization:
Rule 1: Don't do it.
Rule 2, for experts only: Don't do it yet.
Charlton
--
Charlton Wilbur
cwilbur at (no spam) chromatico.net |
|
|
| Back to top |
|
|
|
| Charlton Wilbur... |
Posted: Mon Sep 14, 2009 7:09 am |
|
|
|
Guest
|
Quote: "y" == yitzhak in eretz (sic) <yitzhak at (no spam) yahoo.com> writes:
y> Why does Apple seem to change its XCode interface with each
y> release of Mac OS-X?
Because Apple adds features to Cocoa with each release, and puts
support for the new features into Interface Builder. This requires some
refinement and rearrangement to fit everything in.
If you focus on the concepts rather than on learning where to click,
you'll do better in the long run. The concepts haven't changed, and
once you understand them, it's just a matter of figuring out where Apple
put them in this version.
For the purpose of learning, just make sure the version of XCode and IB
you're using match the materials you're learning from.
Charlton
--
Charlton Wilbur
cwilbur at (no spam) chromatico.net |
|
|
| Back to top |
|
|
|
|
|
All times are GMT
The time now is Sun Nov 29, 2009 11:31 am
|
|