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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:53:28+00:00 2026-06-08T17:53:28+00:00

When I create a new project with Xcode 4.4 and add these lines: NSDictionary

  • 0

When I create a new project with Xcode 4.4 and add these lines:

NSDictionary *test = @{ @"key" : @"test value" };
NSString *value = test[@"key"];
NSLog(@"value is: %@", value);

it compiles with no warnings and executes as expected.

Adding the same lines to an existing project produces the compiler error:

NSString *value = test[@"key"]; <-- Expected method to read dictionary element not found on object of type 'NSDictionary *'

I compared both projects’ target build settings but nothing leapt out at me.

Update:
The new project that successfully compiled was for OSX. I tried another new one for iOS with the above lines and it fails to compile, same as my pre-existing (iOS) project.

  • 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-08T17:53:31+00:00Added an answer on June 8, 2026 at 5:53 pm

    This has nothing to do with old vs. new project, but rather is a factor of the SDK you use. The problem you’re running into is that while this is a compiler feature, it requires SDK support. The iOS 5 SDK does not provide that support, though the iOS 6 SDK does.

    For that reason, now you should just use the iOS 6 SDK. Read on if you want to use object subscripting with the iOS 5 SDK.

    All you need to do is add a header file so that the compiler will try the call. There’s no need to add an implementation; it’s handled automatically by arclite. (If you are not using ARC, you will have to force the linker to include arclite. But you still don’t have to actually switch to it.)

    Create a new interface file, NSObject+subscripts.h.

    #if __IPHONE_OS_VERSION_MAX_ALLOWED < 60000
    @interface NSDictionary(subscripts)
    - (id)objectForKeyedSubscript:(id)key;
    @end
    
    @interface NSMutableDictionary(subscripts)
    - (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key;
    @end
    
    @interface NSArray(subscripts)
    - (id)objectAtIndexedSubscript:(NSUInteger)idx;
    @end
    
    @interface NSMutableArray(subscripts)
    - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx;
    @end
    #endif
    

    I’ve put this chunk on github.

    Note: I used to suggest adding the required methods to NSObject before explaining how to add them only to the relevant objects. In retrospect, I believe this was an error on my part; it led to errors being caught at runtime rather than compile time, unlike the approach now presented here. That approach is still on my blog, but I now believe it to be more of a cool hack than a useful approach.

    Source:

    • Peter Steinberger, Using Subscripting With Xcode 4.4 and iOS 4.3+
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a new project in Xcode (4.2), but I don't need
I have noticed that when you create a new xcode project as a view
If I create a New Project in xcode, then choose View-based Application, the delegate
If you create a new project with Xcode and tell it to create a
I have created a new project in Xcode and performed the following to add
Trying to get custom Done button in Utility Application Create new project in Xcode
Lets go from the start Created New Xcode project,opened interface builder dragged one NSButton
I created a new cordova project on XCODE, I have some files that I
I can't create New Project on my Visual Web Developer 2008 Express with SP1.
When i create new project with the name MyNewProject with a single view application

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.