Welcome to Soft32 Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Noobie Questions

 
   Soft32 Home -> Mac -> Programmer Help RSS
Next:  Dymo Label Software--Hyper Slow  
Author Message
SLR

External


Since: Mar 30, 2009
Posts: 1



(Msg. 1) Posted: Mon Mar 30, 2009 3:55 pm
Post subject: Noobie Questions
Archived from groups: comp>sys>mac>programmer>help (more info?)

Hi everybody. First off, I'd like to say I'm a complete noobie at
Objective C/Cocoa programming, but I'm trying really hard to get
things down. I'm really trying to learn how to program for the iPhone.
I have some questions that are probably extrememly basic, but I
haven't found any real answers for online or in any Objective-C/Cocoa
book (I'm sure the answers are out there, I just can't find it).

1. What is the difference between brackets and parenthesis?

For example, what is the difference between these

[NSString someMethod]

and

(NSString *) someMethod

2. Is there a way to determine object type in an array (or just in
general)?

For example, lets say I had a simple inheritance setup: abstract car
class with subclasses for Honda, Ford, Toyota, Dodge, etc. Now I
create a mutable array of car objects and fill it with various
subclass objects. Is there a function to determine the object type of
a specific element in the array?

3. I am really lost when it comes to creating constants and
enumerations

Lets say I have the following code:

const screenWidth = 320;
const screenHeight = 480;
enum week { Mon, Tues, Wed, Thurs, Fri, Sat, Sun };

Where do I place this code? Does it belong in a header file in the
@interface section or in the @implentation section, or some other
obscure place? I've seen quite a few different opinions online, but
I'd like to learn the correct way to do this.

I apologize if these questions are "too noobish" but I am a beginner.
Also if anyone has any books or websites they'd recommend, I'm all
ears. Thanks in advance.
Back to top
Login to vote
Tom Harrington

External


Since: Aug 19, 2003
Posts: 1921



(Msg. 2) Posted: Mon Mar 30, 2009 5:10 pm
Post subject: Re: Noobie Questions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
<75d8031e-7183-47c5-937d-e918b435aa54 RemoveThis @z23g2000prd.googlegroups.com>,
SLR <Sean.Raborg RemoveThis @gmail.com> wrote:

> Hi everybody. First off, I'd like to say I'm a complete noobie at
> Objective C/Cocoa programming, but I'm trying really hard to get
> things down. I'm really trying to learn how to program for the iPhone.
> I have some questions that are probably extrememly basic, but I
> haven't found any real answers for online or in any Objective-C/Cocoa
> book (I'm sure the answers are out there, I just can't find it).
>
> 1. What is the difference between brackets and parenthesis?
>
> For example, what is the difference between these
>
> [NSString someMethod]

This attempts to call a class method named someMethod on the NSString
class (not on any particular NSString instance). You'd need to add a
semicolon to make it complete. Even then it would only compile if
"someMethod" is actually a placeholder you're using for a method that
actually exists on NSString.
>
> and
>
> (NSString *) someMethod

This is (almost) a declaration of a method that takes no arguments and
returns an NSString. To be complete it needs either a "+" or "-" at the
start to indicate whether it's a class method or an instance method.

> 2. Is there a way to determine object type in an array (or just in
> general)?
>
> For example, lets say I had a simple inheritance setup: abstract car
> class with subclasses for Honda, Ford, Toyota, Dodge, etc. Now I
> create a mutable array of car objects and fill it with various
> subclass objects. Is there a function to determine the object type of
> a specific element in the array?

You can call the "class" method on any object to get a reference to its
class object. You can use "isKindOfClass" to ask an object if it's an
instance of a specific class.

> 3. I am really lost when it comes to creating constants and
> enumerations
>
> Lets say I have the following code:
>
> const screenWidth = 320;
> const screenHeight = 480;
> enum week { Mon, Tues, Wed, Thurs, Fri, Sat, Sun };
>
> Where do I place this code? Does it belong in a header file in the
> @interface section or in the @implentation section, or some other
> obscure place? I've seen quite a few different opinions online, but
> I'd like to learn the correct way to do this.

There's no single right answer, it depends on where you want those
declarations to be available. C scoping rules offer a variety of
solutions depending on what you need to have happen.

--
Tom "Tom" Harrington
Independent Mac OS X developer since 2002
http://www.atomicbird.com/
Back to top
Login to vote
Andrew

External


Since: Feb 27, 2007
Posts: 27



(Msg. 3) Posted: Tue Mar 31, 2009 7:20 pm
Post subject: Re: Noobie Questions [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2009-03-30 23:55:53 +0100, SLR <Sean.Raborg.RemoveThis@gmail.com> said:

> Hi everybody. First off, I'd like to say I'm a complete noobie at
> Objective C/Cocoa programming, but I'm trying really hard to get
> things down. I'm really trying to learn how to program for the iPhone.
> I have some questions that are probably extrememly basic, but I
> haven't found any real answers for online or in any Objective-C/Cocoa
> book (I'm sure the answers are out there, I just can't find it).
>
> 1. What is the difference between brackets and parenthesis?
>
> For example, what is the difference between these
>
> [NSString someMethod]

This cites the method ("some method" that should be called to an object
{NSString)

>
> and
>
> (NSString *) someMethod

The brackets imply a casting. "someMethod" must return a NSString object

>
> 2. Is there a way to determine object type in an array (or just in
> general)?
>
> For example, lets say I had a simple inheritance setup: abstract car
> class with subclasses for Honda, Ford, Toyota, Dodge, etc. Now I
> create a mutable array of car objects and fill it with various
> subclass objects. Is there a function to determine the object type of
> a specific element in the array?

Just guessing here. I think you'd call (BOOL) isKindOfClass.

>
> 3. I am really lost when it comes to creating constants and
> enumerations
>
> Lets say I have the following code:
>
> const screenWidth = 320;
> const screenHeight = 480;
> enum week { Mon, Tues, Wed, Thurs, Fri, Sat, Sun };
>
> Where do I place this code? Does it belong in a header file in the
> @interface section or in the @implentation section, or some other
> obscure place? I've seen quite a few different opinions online, but
> I'd like to learn the correct way to do this.

I'd be inclived to put in the header file under interface

>
> I apologize if these questions are "too noobish" but I am a beginner.
> Also if anyone has any books or websites they'd recommend, I'm all
> ears. Thanks in advance.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
diskarb questions - Does anyone have any good docs or idea of the best way to make sure that when you tell the Disk arbitration server to..

Quicktime Questions... - Hi there, I try to connect a simple custom progress-bar to a quicktime Movie, so if the movie plays the progressbar..

Questions about QT - Dear QT Programmers, I am new to QT programming. I have used it a long time ago. Please help me figure out how to..

NSOutlineView - some questions - Hello NG, I have a NSOutlineView as part of a NSSplitVIew like in mail app. 1. I want to update the root- or parent-....

beginner's questions - I love my mac! I can do anything on that I can do on a PC except for programming it. when I used Windows (i still..

ASynch read questions? - Hello, Is there any important difference between PBReadForkAsync and PBReadAsync, other than the fact you're..
       Soft32 Home -> Mac -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum

Categories:
 Windows
 Linux
  Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]