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 9163807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:31:57+00:00 2026-06-17T14:31:57+00:00

I have a class in objective C which represents a generic business object (

  • 0

I have a class in objective C which represents a generic business object ( let’s say for my question sake its a bankaccount). I have a java C# background (FYI ). Now this bankAccount has an enum property defining what type it is, plus an NSURl property

        //this is in the bankAccount.h file
        typedef enum {Checking, Savings, Investor} AccountType;
        -(NSURL *)url;

Now users can create a new bankaccount and set the enum to the relevant type. after allocating their new bankaccount object they might need to access the url property, so I have to implement a getter for that property which will initialize it properly. My question here is that how can I know what type of a bankaccount the calling class has created of my bankaccount in order to initialize the url property correctly?

like right now this is how I am implementing url in the bankaccount.m file :

 -(NSURL *)url {   
       if (url != NULL) {
       return url;
       }
  NSString *filePath;
  // figure out the file path base on account type
  switch (AccountType) {
  }

  return url;

}

keep in mind that this is in the Bankaccount.m file, which really doesn’t know in the calling class what is the instance being created is. Maybe I am confused and maybe its a simple answer but I can’t wrap my head around this concept.

Appreciate the help guys.

  • 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-17T14:31:58+00:00Added an answer on June 17, 2026 at 2:31 pm

    I think youre forgetting that you can’t exactly save information in an enum. Save the value of the enum in some variable.
    You do not necessarily have to setup your code like this, but maybe this is more what you are looking for.

    // BankAccount.h
    #import <Foundation/Foundation.h>
    typedef enum {
        Checking = 1,
        Savings = 2,
        Investor = 3
    } AccountType;
    
    @interface BankAccount : NSObject
    -(void)setAccountType:(AccountType)theType; //Setter
    -(NSURL *)url;
    @end
    
    // BankAccount.m
    #import "BankAccount.h"
    @implementation BankAccount
    
    -(void)setAccountType:(AccountType)theType {
        self.bankAccountType = theType;
    }
    
    -(NSURL *)url {
        NSURL *someUrl;
        switch (self.bankAccountType) {
            case Checking:
                someUrl = [NSURL URLWithString:@"http://xzyChecking"];
                break;
            case Savings:
                someUrl = [NSURL URLWithString:@"http://xzySavings"];
                break;
            case Investor:
                someUrl = [NSURL URLWithString:@"http://xzyInvestor"];
                break;
            default:
                someUrl = [NSURL URLWithString:@"http://xzyError"];
                break;
        }
        return someUrl;
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an objective-C++ class which contain some honest C++ object pointers. When the
I have an Objective-C class which one of it's variables is an C++ object
I'm new in objective-C and i wonder if its correct: I have a class
I have a configuration class in my objective-c app which reads a PLIST file
I have a simple question about creating multiple initialisers within an objective-c class. Basically
I have a class called CookieMonster, its objective is to simply create a cookie
I have an Objective C++ class, instances of which are required to store an
I have a class 'DOInstance' which I inherit later on. Here's its declaration: @interface
I have the following objective C class. It is to store information on a
I have a peculiar problem. I created a normal Objective C class called SampleTable.

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.