Returning a NSString and float in a method..is it possible?

Hello all,

I’m new to objective-c. I want to declare in my method a string and a float and i would like to have the two returned as well.

It’s like this: I want the method to take input for a student’s course and the mark associated to the course.

I cannot figure out the syntax in declaring this so i’m hoping someone here can help. I’m working this out on my own and i don’t have a teacher to go to rather a book and various forums and i’m stuck. Perhaps it’s my logic too so please feel free to tear it apart.
Thanks to everyone here who replies and adds insight to my puzzle.

I have this so far:
INTERFACE
@interface Student: NSObject
{
NSString *subject;
float mark;
}

@property NSString *subject, float mark;

//method that will return both

  • (NSString*) newSubject: (float) newMark;
    @end

IMPLEMENTATION
#import “Student.h”
@implementation Student

@synthesize subject, mark;

//method to return the subject and mark

  • setSubject: (NSString *) newSubject: (float) newMark
    {
    newSubject = [self subject];
    newMark = [self mark];
    return newSubject, newMark;
    }
    @end

It seems you are thinking in the wrong direction. In Objective-C you deal with classes and instances/objects of classes. Regarding your example, subject and mark are part (instance variables/properties) of a class called Student. So if you create an object of the class Student there is no need to return every property (mark and subject) apart - just return the object.
I really would recommend you to buy a good Objective-C book, like the one of Aaron and Adam. First of all you need to know what object oriented programming means. Your code will not work this way.

btw, if you post code snippets please use the editors code tags - it will be much easier to read.

cu
Vertex