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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:03:56+00:00 2026-06-18T04:03:56+00:00

Attempting to get an enumerated value by an index from a NSMutableArray property that

  • 0

Attempting to get an enumerated value by an index from a NSMutableArray property that is filled with enumerated values.

all I wanted is to set a dynamic property and get set back within class instance.

thus,
I coded a clear example that expose of problem.

Problem is this. WriteByType method in example never gets correct value.
it should log “You Get Right Arrow” but it doesn’t

//----------------------------------------------------------
//  CCMyClass.h
#import <Foundation/Foundation.h>

typedef enum {
    aLeft,
    aRight
} Arrow;

@interface CCMyClass : NSObject
{
    NSMutableArray *_arrowsPkg;
}
@property(nonatomic,copy) NSMutableArray *arrowsPkg;
@property (nonatomic)int nextPkgIndex;
-(void)GetItemOne;
@end
//-------------------------------------------------------------
//  CCMyClass.m
#import "CCMyClass.h"

@implementation CCMyClass
@synthesize arrowsPkg=_arrowsPkg;

-(void)WriteByType:(Arrow)AArrow
{
switch (AArrow) {
    case aLeft:
        NSLog(@"You Get Left Arrow");
        break;
    case aRight:
        NSLog(@"You Get Right Arrow");
        break;
    }
}

-(void)GetItemOne
{
    Arrow a =(Arrow)[[self arrowsPkg]objectAtIndex:1];
    [self WriteByType:a];

}
@end
//---------------USAGE EXAMPLE----------------------------------------------
//  CCAppDelegate.m
- (IBAction)btn1Clicked:(id)sender {

    CCMyClass *c1=[[CCMyClass alloc]init];
    NSNumber *v1=[NSNumber numberWithInt:aLeft];
    NSNumber *v2=[NSNumber numberWithInt:aRight];

    NSMutableArray *arr1=[NSMutableArray arrayWithObjects:v1,v2, nil];
    [c1 setArrowsPkg:arr1];
    [c1 GetItemOne];
}
  • 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-18T04:03:57+00:00Added an answer on June 18, 2026 at 4:03 am

    Replace

    Arrow a = (Arrow)[[self arrowsPkg] objectAtIndex:1];
    

    with

    Arrow a = (Arrow)[[[self arrowsPkg] objectAtIndex:1] intValue];
    

    or, more clearly written

    NSNumber *arrowNumber = [[self arrowsPkg] objectAtIndex:1];
    Arrow a = [arrowNumber intValue];
    

    You are storing your Arrow enum types in NSNumber in btn1Clicked:, so you need to unbox these values in GetItemOne from NSNumber * types to the earlier int values.

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

Sidebar

Related Questions

I'm attempting to get all order items from the last 24 hours. I have
I am attempting to enumerate the set of all pairs made of elements from
I'm attempting to get a set of list items from sharepoint via the WebService.
Im attempting to get a block of text from a file I have already
I'm attempting to get order data from a Yahoo store. I'm using the docs
I am attempting to get a distinct list of id's back that would be
I am attempting to get information from an HTML form to a PHP script.
I am attempting to get a list of Farm Features from a SharePoint 2010
I am attempting to get some custom objects from the CollectionChanged event of a
I'm attempting to get the content-length of a remote file so that I can

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.