Quick Question: When to use ( ) and when to use [ ] and why the ( *)

Hi all,
A quick question that i'm sure is very simple but is slightly confusing me. I've just started trying to learn Objective-C and am a little confused by ( ) and [ ].
I get that you use the [ ] brackets when you want something specific from an object, i.e.
[ textField textColor ]
and that you use ( ) brackets for things like:
if ( x == y) {
But I get confused when I see things like:
NSLog(@"some text here");
Why does that get ( ) brackets and why is it not [ ].
Also another point of confusion, creating methods... Why are some methods done like:
- (void)awakeFromNib
And others done like (with the additional "*" added):
- (NSString *)stringvalue
As I said, I'm sure this is very simple and obvious, but it is confusing me slightly.
Thanks in advance!

Adam:
As you already know, square brackets are used to send a message to an object, so if a object like myObject implements the method -doSomething, you can call it with:
\[myObject doSomething\];
The other use square for brackets have is to index C-style arrays, such as:
aValue = anArray\[10\]; // Get the 10-element of an array
However, because C-style arrays are rarely used in Cocoa applications (use NSArray instead) you will not see this situation often.
Parenthesis in expressions are used to group and prioritize, such as:
x = 10 * (3 + 5); // x = 80
If () statements use it to delimit the test expression. Same with while (). for () uses it to enclose the limits and increment statements, etc.
The other important use of parenthesis is in calling a C function:
result = foo(3);
means that you are calling the function named foo with the argument 3, and storing the the return value in the variable 'result'. This is different from a message because a C function is not a method of an object. They exist independently of any objects. NSLog() is a function defined within Cocoa but it is not a method. So, you call it with the traditional C function call syntax. Cocoa defines other functions like NSStringFromRect(), which takes an NSRect as argument and returns a pointer to an NSString.
And that leads me to your last question. Some methods return simple types, like int, float, or void (i.e. returns no value). These methods will have prototypes like:
\- \(void\)returnNothing;
\- (int)returnInteger;
Other methods return pointers to types, like:
\- (int \*)returnPointerToInteger;
\- (void \*)returnPointerToAnything; // In obj-C one typically uses id instead of void*
Returning whole objects from methods has problems and it is better to just return a pointer (the address in memory) instead:
\- (NSString *)makeAString;
The method above returns a pointer to an NSString rather than the entire object.
Good luck with your learning,
Juan-Pablo
Message was edited by: Juan Pablo Claude

Similar Messages

  • HT4623 when i doing my update my ipad 3 why the itunes show this message ? (the ipad could not be restored this device isn't eligible for the requested guid ) what can i do now please reply urgent thanks

    when i doing my update my ipad 3 why the itunes show this message ? (the ipad could not be restored this device isn't eligible for the requested guid ) what can i do now please reply urgent thanks

    Make sure you have the latest software on your computer (tap to enlarge image)

  • HT1766 Whenever I try to backup my ipad to iCloud, I get the following error message and can't work out why " the last backup could not be completed" I am connected to my wi FI and iPad off and connected to power. Please can anyone help ?

    Whenever I try to backup my ipad to iCloud, I get the following error message and can't work out why " the last backup could not be completed" I am connected to my wi FI and iPad off and connected to power. Please can anyone help ?

    In settings>general> cellular do you have it  turned ON?

  • Hi. Quick question I am working with Panasonic GH3 footage and it is playing back in slow motion?

    Hi. Quick question I am working with Panasonic GH3 footage shot using .MOV wrapper with their IPB 50mbps and All-Intra 72MBPS codecs and they are playing back in slow motion in Sg CC. The footage works fine in PP CC and I have no clue on how to fix it. Is this a bug or do I a have a setting wrong some place?

    Yes it turns red this is silly PP and AE have no problem with playback for these codecs. So it is indeed Sg not handling the codec correctly and not my system?
    What if I transcoded it to something else other than the previous what would you reccommend?
    I was going to transcode to ProRes but 5DtoRGB does not work on Windows with GH3 codecs.
    What is the correct time warp seting under clip properties? I screwed with it and forgot the default setting.
    Is there a way to reset Sg back to defaults settings globaly. I tried to many settings trying to fix the playback and may have left something in the wrong state.
    Thanks...

  • WHY THE IPHONE GETTING HOT WHEN USING 3G PLUS WITH DATa?, WHY THE IPHONE GETTING HOT WHEN USING 3G PLUS WITH DATA?

    why my iphone 4s getting hot when using 3g plus with data?
    then my phone left side speaker didnt work when i list songs?

    It is normal for the phone to get hot when your using data such as YouTube videos, streaming music etc.. And as for the left speaker not working, the left speaker is a microphone, the right one is for sound. Don't worry, everything your iPhone is doing is normal.

  • Can you look at my code and give me any idea why the pie garph doesnt show?

    Hi..
    i use beans to create an pie graph and i dont know how i can add data to it,i mean what data must be pass to it.. as u know in column and line graph there is an x-axis and y-axis and in pie there no x or y axis..i need 2 categories and one value to put on it.
    and the code is :
    CURSOR C_DETAIL IS
    SELECT REF_TYPE ,
    REF_YEAR ,
    REF_NUM ,
    ACT_DATE ,
    UNREL_PROF_LOSS , ----------------->(value)
    TO_CHAR(ACT_DATE , 'DD/ MM/ YYYY') ,----------->(Category1)
    LPAD(TO_CHAR(REF_TYPE),2,'0')||'/'||
    LPAD(TO_CHAR(REF_YEAR),2,'0')||'/'||
    LPAD(TO_CHAR(REF_NUM),6,'0') "DEAL_NUM"--------->(Category2)
    FROM BOND_ACT
    WHERE ISSUE_NUM = :KEY.ISSUE_NUM AND
    ISSUE_NUM_ABB = :KEY.ISSUE_NUM_ABB AND
    ISSUER_ID = TO_NUMBER(:KEY.ISSUER_ID ) AND
    ACT_DATE >= TO_DATE(:KEY.FROM_DATE,'J') AND
    ACT_DATE <= TO_DATE(:KEY.TO_DATE,'J') AND
    ACT_TYPE = 6
    ORDER BY REF_TYPE , REF_YEAR , REF_NUM , ACT_DATE;
    BEGIN
    set_custom_property('CHART_DISP.SIMPLEGRAPH',1,'CLEAR_GRAPH','');
    SET_CUSTOM_PROPERTY('CHART_DISP.SIMPLEGRAPH',1,'DEBUG','TRUE');
    VD := ',';
    COUNTER := 0;
    OPEN C_DETAIL;
    FETCH C_DETAIL INTO var1,var2,var3,var4,value,Category1,Category2;
    while (C_DETAIL%FOUND) LOOP
    CDATA := X||VD||'PIE GRAPH'||VD||X;                    
    set_custom_property ('CHART_DISP.SIMPLEGRAPH',1,'ADD_ROWDATA',CDATA);
    COUNTER := COUNTER +1;
    FETCH C_DETAIL INTO var1,var2,var3,var4,value,Category1,Category2;
                   END LOOP;
                             SET_CUSTOM_PROPERTY('CHART_DISP.SIMPLEGRAPH',1,'GRAPHTYPE','PIE_GRAPH');
                             SET_CUSTOM_PROPERTY('CHART_DISP.SIMPLEGRAPH',1,'COLUMNCOUNT','');
    set_custom_property('CHART_DISP.SIMPLEGRAPH',1,'ADD_DATA_TO_GRAPH','');
    CLOSE C_DETAIL;
    set_custom_property('CHART_DISP.SIMPLEGRAPH',1,'SHOW_GRAPH','');
    EXCEPTION
         WHEN OTHERS THEN
         MESSAGE('SQLCODE='||SQLCODE||SQLERRM);
         MESSAGE('SQLCODE='||SQLCODE||SQLERRM);
    end;

    Hi,
    please see the html help file (graph90.html) that comes with the Graph bean sample. The debug option is enabled with a call to set_custom_poperty('blockname.beanarea',1,'DEBUG', true)
    The messages are written to teh JInitiator console (see right bottom corner of windows to open)
    Frank

  • My iphone 4 lock screen/power button is not working, nothing spilled on it and not dropped, any idea why the button won't work?

    My iphone 4 lock screen/power button just stopped working.  nothing spilled on it and not been dropped.  Any idea why it stopped working?

    Kat Goddess wrote:
    Any idea why it stopped working?
    I have no idea why it stopped working.  But why it failed does not matter.
    Take it to an Apple Store or Authorized Apple Repair Center and have it assessed and see what it would take to get it working.

  • Quick question(For people who know about video formats and stuff)

    What type of media file is AVI? Because I looked on the list of codecs compatible with iPod and it didn't say if it was compatible or not, maybe it's something else. If you know, please tell me

    For the formats that were not compatible, I converted them, and it then played the video, but with no sound. I want to get South of Nowhere for a friend on my ipod, butt he only format they come in is AVI and MPG. MPG is quicktime, I know that so it won't work. But what is AVI. Of course I could buy it from the iTunes music store, but I am a kid with no credit card, and my parents wouldn't dare trust me with that

  • Can U look at my code and give me any idea why the scatter garph didnt work

    Hi,
    i use this code to create a scatter graph using bean in oracle 10g forms and it didnt show the points.. it only show an empty graph although the cursor return data..Please if anyone know whats the problem i would be so thankful.
    And here is the code:
    DECLARE
    cursor c is
    SELECT
    FRA_YEAR, -----> X
    TOTAL_AMT_IN_BASE -----------> Y
    FROM TMP_GRPH
    ORDER BY FRA_YEAR;
    cdata varchar2(2000);
    vd varchar2(2);
    X NUMBER;
    Y NUMBER;
    COUNTER NUMBER;
    cdata varchar2(2000);
    vd varchar2(2);
    X NUMBER;
    Y NUMBER;
    COUNTER NUMBER;
    BEGIN
    set_custom_property('CHART.SIMPLEGRAPH',1,'CLEAR_GRAPH','');
    SET_CUSTOM_PROPERTY('CHART.SIMPLEGRAPH',1,'DEBUG','TRUE');
    VD := ',';
    COUNTER := 0;
    OPEN C;
    FETCH C INTO X,Y;
    while (C%FOUND) LOOP
    CDATA := X||VD||X||VD||Y||VD||Y;
    set_custom_property('CHART.SIMPLEGRAPH',1,'ADD_ROWDATA',CDATA);
    FETCH C INTO X,Y;
    END LOOP;
    set_custom_property('CHART.SIMPLEGRAPH',1,'GRAPHTYPE','SCATTER_GRAPH');
    set_custom_property('CHART.SIMPLEGRAPH',1,'ADD_DATA_TO_GRAPH','');
    CLOSE C;
    set_custom_property('CHART.SIMPLEGRAPH',1,'SHOW_GRAPH','');
    EXCEPTION
    WHEN OTHERS THEN
    MESSAGE('SQLCODE='||SQLCODE||SQLERRM);
    MESSAGE('SQLCODE='||SQLCODE||SQLERRM);
    end;
    note:
    FRA_YEAR is the X-axis
    TOTAL_AMT_IN_BASE is the Y-axis
    Thanks alot
    Eyad Basheer

    Hi,
    please see the html help file (graph90.html) that comes with the Graph bean sample. The debug option is enabled with a call to set_custom_poperty('blockname.beanarea',1,'DEBUG', true)
    The messages are written to teh JInitiator console (see right bottom corner of windows to open)
    Frank

  • Using Brightness & Contrast filter in FCP (Why the lighting/color shifts??)

    I'm using the standard Brightness & Contrast filter that comes with FCP but when I do so the video I apply it to has crazy shifts in color and lighting, any help with getting rid of these or at least minimizing them would be much appreciated!
    Thanks
    Kevin

    The Brightness and Contrast filter in FCP is worthless, plain worthless and does more damage than good. Same with the Proc Amp filter which along with the B&C filter should be eliminated from the FCP tool kit.
    As Mr. X. has rightly stated, use the 3way. Get to know it intimately as it does darn near everything you need to accomplish.

  • How to get why the validation has failed.when using isSchemaValid() ?

    Oracle 11.2
    to validate xmlType I use a procedure within isSchemaValid - function,
    But when it returns 0,
    where from to get why the validation is failed ?
    regards

    Thats the reason why you should use SchemaValidate(), because its more informative
    See for an example here: Re: catching error while validating an xml file

  • Simple Quick Question

    wrong section, post was moved.
    Message was edited by:
    Rob17

    you titled "simple quick question"...
    .. complicated to answer..
    a) the TermsOfUse of the iTS don't allow any processing of purchased files, these are "copy protected"..
    b) iM has a voice-over function..
    c) iM is a video-edit app.. easy to use... just learn to handle it...
    d) iM allows to "extract" audio (=muting the original audio, adding your own..)
    e) to learn iM, spend some time here: http://www.apple.com/ilife/tutorials/imovie/index.html
    f) use pencil and paper first! WRITE and scribble, what shall happen when in your movie/parody... make a script, draw a storyboard .. THEN launch iM.. in other words: think first, then edit.. iM is just a tool, it does not "create"... Picasso needed a papertowel and half a stencil to create art....
    g) to get comfortable with iM, start with your own, small, short (3min!) project... import some stills, edit them, add a funny voice-over, add sounds, add music... good? make a bigger one...
    h) .. in our Lecture II, we teach you how to import shows from TV, youtube, wherever..
    standard disclaimer:
    be nice to ©opyrights ...

  • Quick question re select-options

    Hi
    I am relatively new to ABAP but have a quick question:
    I need to create a select-options which does the following:
    1. Allows ONLY "equals" signs
    2. Disallows intervals
    3. Disallows the use of ranges in the multiple selection box.
    4. Allows multiple individual selections.
    I can achieve most using the following:
    select-options s_knvh for knvh-kunnr no intervals.
    However, this still allows ranges using the multiple selection box, and also allows the "not equal to" option.
    Adding the "no-extension" syntax simply removes my ability to use multiple individual entries.
    Any ideas?
    Thanks
    Jon

    Use this FM.
    SELECT_OPTIONS_RESTRICT

  • Quick question - which group owns this file? -rw-r--r--@ 1 admin -  Daemon?

    As per subject line. if i type "id 1" in terminal the uid is daemon - meaning admin is the group - is this correct? If it is - why is one part of the result a uid and one a name? Why the @?
    -rw-r--r--@ 1 admin 1656
    (It's a script by the way)

    It's hard to say since it looks like the line was typed in (as opposed to copied and pasted), and the line doesn't appear to be complete (I'm assuming it's the output of 'ls -l').
    But actually, going by position, the "1" is the number of links - and since your system has a user with 'uid=1' configured ('daemon'), then ls -l should list the name rather than the number, so the "1" probably is the number of links rather than the "owner".
    Then that would make the file's owner "admin" (which is very odd - try 'id admin'), and the group an undefined numerical value, representing the 'gid=1656'. Or else it's the size and a column is missing from the post.
    The "@" means the file has extended attributes (see the 'man" page for 'ls'). You can also try 'ls -l@ filename' or 'xattr -l filename'

  • Can't specify the customer to use a new sales order type ,why?

    I created a new sales order type, finished the configeration.. but when I use it to create a order by t_code VA01 ,input the order type and sales area ,then enter, why the sold-to-party and ship-to-party are inmodifiable? i can't specify the customer... where is the problem?
    appreciate you help.thank you !

    Hi Sue,
             I think u havent did the Partner determination for that Sales document.  If you create ur own sales doc type in VOV8 ,new entries.
    U need to maintain the Partner determination for that sales doc type.
    this is the same,the way u maintaint the customer partner determination.
    If you dont maintain this , in VA01 screen, u cant able to enter Sold to & ship to parties as it will be in display mode. I think the same error ur getting know as per ur issue.
    This will def solve ur issue as i faced n overcome long back.
    *reward points ,if helpful

  • Broadband usage has doubled and I don't know why

    Hi there
    Just received a warning message that I am about to exceed my 40gb limit.  Normal monthly usage has been 18gb apparently and we don't know why the increase has occurred.  We have no kids at home, we don't stream films or videos or play games, I've downloaded 1 music album this month and we've surfed the net as usual.
    Can this usage be verified?
    Any tips on checking whther someone else is using our broadband....is this possible?
    Any tips on why this might be happening...it's puzzling.
    Is there an indpependent (non BT) way of monitoring and measuring broadband usage?
    Dom

    Hi dr58.
    In my experience the only way to sort this out is to hope that your post draws the attention of a forum moderator. Anyone on the phones will try and convince you that you are indeed downloading 20 albums a day, uploading 3000 pictures a week etc etc and "it all mounts up" and you would be far better on an Unlimited Package.
    I had problems (in fact thinking about it, this time last year) where my usage had crept up and according to BT my son and I were using 90gb a month, despite no streaming, gaming etc. I am on a 40gb package like yourself so was incurring £50 charges each month. In the end it was resolved with BT agreeing it wasn't possible for us to be getting through that amount but as I wasn't using a BT router at the time it was impossible to prove that someone hadn't been piggybacking my wifi. (I'd changed passwords during the high readings to no avail anyway).
    My personal advice would be to keep a daily eye on your broadband monitor, screenshot them if need be, if you have been out during the day or away for any great length of time also note the readings that appear for that day. I also check my BT homehub to make sure only the devices in my house are hooked in just in case.
    As it happens I've also noticed a big jump in my readings this month, I have just a few GB to spare but in my opinion the readings are still high compared to what I was noting at the tail end of last year after I finally had SeanD look into the matter for me.
    I do hope that the meters arent going up the creek yet again because I've sworn that if it should happen again I'm walking to a different company this time around.
    Best of luck and I hope you get the information you need and the situation resolves itself.

Maybe you are looking for

  • Audiobook no longer playing correctly on iPod

    My iPod touch is a 4th generation and has, until this point, worked quite well. I have Harry Potter audio books that I ripped from CDs eons ago on my iTunes. In iTunes they play marvelously; however, on my iPod they sometimes cut into other books all

  • ITunes 11.0.4 gives blank error message when opening with OS X 10.6.8

    I canot get iTunes to open at all with either my admin or guest account.  I have already run the repair permissions utility.  Any suggestions?

  • Quicktime 7.5.5 Crashes (iMovie 6.0.4 related?)

    i have been having major problems with quicktime 7.5 -- and now with the upgrade to 7.5.5. i have no problem using the iMovie expert settings to export a QT .mov that can be uploaded and viewed perfectly through Firefox, but when i try and open the f

  • Converting .mov to .cdr for viewing

    Hello all, I have a bunch of .mov files of training videos, but I can't play them on my computer screen and use the program at the same time, so I want to play them on my standard DVD player on a TV. What is the process through which I can get my .mo

  • Never looked at Mac until now

    Hello, I know enough about computers (PC's) to be dangerous. 2 years ago I bought a Gateway notebook and have had unbelievable issues with it. For the last year, it has begun to just shut off on it's own while being used. When it does this, you can't