954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

From java method to an objective-c method

I have been doing java for almost 3 years now, am just starting to learn Objective-C as of this past June.

Been writing a few programs on my own and writing programs for the exercises in 2 very cool Cocoa/objective-c books.

My question is how do I, coming from Java, create a method in @interface? I want to be able to take my java program of 2 years in the making, and move it to objective-c coding. Below is the method in java

public void calculations(double loan, int termYears, double rate, double taxes, double insurance, double downPayment, double addPmt, double squareFeet, double salary)


Now how do I transform this method?

- (void)     calculations: (double) loan  :  (int) termYears  : (double) rate   : (double) taxes   : (double) insurance   : (double) downPayment   : (double) addPmt   : (double) squareFeet   : (double) salary;


Is this correct?

musikluver4
Junior Poster in Training
81 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

You're almost there. But this is the correct one.

(void)     calculations: (double *) loan  :  (int *) termYears  : (double *) rate   : (double *) taxes   : (double *) insurance   : (double *) downPayment   : (double *) addPmt   : (double *) squareFeet   : (double *) salary;
anilkumar-m
Newbie Poster
6 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
 

how come you didn't use the - (void)? you just did (void)? It says something in the book about that and I read that + is used too...

musikluver4
Junior Poster in Training
81 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
 

oops... sorry missed it by mistake. +/- are about class/instance methods in Objective-c

anilkumar-m
Newbie Poster
6 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You