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

  • Home
  • SEARCH
  • 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 7993645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:54:52+00:00 2026-06-04T13:54:52+00:00

I am a very green nubie, anyways, I am working through a tutorial that

  • 0

I am a very green nubie, anyways, I am working through a tutorial that walks me through using the NSLocale class to get the local currency, like this:

NSLocale *here = [NSLocale currentLocale];
NSString *currency = [here objectForKey:NSLocaleCountryCode];
NSLog(@"Money is %@", currency);

So, I understand that I am creating an instance of the NSLocale class called ‘here’, then I send the ‘here’ object a message asking for the objectForKey, and the result is returned into the NSString, called ‘currency’. Last, I print the currency value with the NSLog.

Ok, so here’s my question, I then reviewed what other methods are on the NSLocale class and I found one called ‘preferredLanguages’, it returns an array of the preferred languages. So I though I would call that method and then print it to the log, just for grins and to help me learn. Going off of the example above, I figured I would call it like this. Starting with the fact that I already have an instance of the NSLocale class called ‘here’ from the code above, I thought that I would just need the following ( I am repeating the three lines above just so it is easy to read here. )

NSLocale *here = [NSLocale currentLocale];
NSString *currency = [here objectForKey:NSLocaleCountryCode];
NSLog(@"Money is %@", currency);

NSArray *prefLangs = [here preferredLanguages];
NSLog(@"Preferred Languages are: %@", prefLangs);

But that didn’t work, I got an error message that said, “No visible @interface for ‘NSLocale’ declares the selector ‘preferredLanguages’

I figured out that I must do it this way instead:

NSLocale *here = [NSLocale currentLocale];
NSString *currency = [here objectForKey:NSLocaleCountryCode];
NSLog(@"Money is %@", currency);

NSArray *prefLangs = [NSLocale preferredLanguages];
NSLog(@"Preferred Languages are: %@", prefLangs);

I just don’t understand why I had to call the method like this: [NSLocale preferredLanguages], instead of [here preferredLanguages]. The instance of ‘here’ is already created above. Can someone please explain.

  • 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-04T13:54:54+00:00Added an answer on June 4, 2026 at 1:54 pm

    You’ll get accustomed to the joy and pain of Objective C pretty quick, but the short answer involves looking at the method declaration, which looks like:

    + preferredLanguages:

    The “+” in the declaration indicates it’s a class method.

    Here’s a relevant paragraph from Apple’s “Learning Objective C” document

    A class in Objective-C can declare two types of methods: instance
    methods and class methods. An instance method is a method whose
    execution is scoped to a particular instance of the class. In other
    words, before you call an instance method, you must first create an
    instance of the class. Class methods, by comparison, do not require
    you to create an instance, but more on that later.

    If the declaration starts with a “-“, that makes it an instance method and you need to have an instance instantiated (created) in order to call methods on that object.

    Hopefully this makes sense so far.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We do automated builds using Nant and CruiseControl.net. I'm very green when it comes
I'm just beginning a very simple pygame code that draws a green line on
I have recently started working on a very large C++ project that, after completing
SISS 2008 - My package goes green very quickly, but does nothing. The connections
I have a very basic page with two elements, an outer green box, and
Data in this fashion: [Array1] = ['blue','green', 'yellow','red','very very red'] [Array2] = ['ColumnA','ColumnB','ColumnC','ColumnD','ColumnD'] This
Very occasionally, despite all testing efforts, I get hit with a bug report from
This must be a really stupid question, but I'm still very green when it
I'm making a very simple ad button system using ASP.NET 2.0 The advertisment is
I'm very new to Java and am having some issues looping through JCheckBoxes on

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.