Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:40:20+00:00 2026-06-14T07:40:20+00:00

First day learning Objective-C but have a java background. I’d like to use the

  • 0

First day learning Objective-C but have a java background. I’d like to use the same variable name for my parameter that I do for my instance variable. In java we do it like this

public class Person
{
    private String name;
    private String age;

    public void setName(String name)
    {
        this.name = name;
    }
    public void setAge(String age)
    {
        this.age = age;
    }
}

In objective c so far I have this

@interface Person : NSObject
{
    int age;
    int name;
}
    -(void) setAge:(int) age;
    -(void) setName:(int) name;
    -(int) getAge;
    -(int) getName;
@end

@implementation Person
-(void) setName:(int) w
{
    weight = w;
}
-(void) setAge:(int) a
{
    age = a;
}
-(int) getName
{
    return name;
}
-(int) getAge
{
    return age;
}
@end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:40:21+00:00Added an answer on June 14, 2026 at 7:40 am

    In Objective-C, you can define your own accessors or use @syntehsize to create them automatically for you.

    In the case where you want to define accessors manually, setters are declared like this:

    - (void)setName:(NSString *)name {
    
        self.name = name;
    }
    
    - (void)setAge:(NSInteger)age {
    
        self.age = age;
    }
    

    For getters, you simply declare them as follows:

    - (NSString *)name {
    
        return self.name;
    }
    
    - (NSInteger)age {
    
        return self.age;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today is my first day learning java :) I'm having problems running a very
Alright this is my first day with JQuery so have fun with these functions
I am first day with SOLR, and of course, i have some problems with
I have a monthly table (only holds rows with first day of month, and
I have been slowing learning and building my first android app. I'm VERY new
I'm just learning c++ (first day looking at it since I took a 1
Right, day 8 learning php and I feel that I have tried to do
I am learning about tools like Chef/Puppet/etc for the first time and was wondering
I am learning Java and have a pretty basic problem. I am indexing some
This is my first day playing with CI and I really like it so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.