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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:35:50+00:00 2026-05-25T15:35:50+00:00

I am getting NSCFString Errors passing the results of a text string converted into

  • 0

I am getting NSCFString Errors passing the results of a text string converted into an array to a method that expects strings.

I have a feeling that the problem is that there is something wrong with the array conversion but i am not clever enough to work this out !!!

here’s the .h file

@interface RootViewController : UIViewController <ZXingDelegate> {
IBOutlet UITextView *resultsView;
NSString *resultsToDisplay;

IBOutlet UITextField *ItemNo;
NSString *ItemNoToDisplay;

IBOutlet UITextField *VariantCode;
NSString *VariantCodeToDisplay;

IBOutlet UITextField *Description;
NSString *DescriptionToDisplay;

IBOutlet UITextField *Qty;
NSString *QtyToDisplay;

}

@property (nonatomic, retain) IBOutlet UITextView *resultsView;
@property (nonatomic, copy) NSString *resultsToDisplay;

@property (nonatomic, retain) IBOutlet UITextField *ItemNo;
@property (nonatomic,copy) NSString *ItemNoToDisplay;

@property (nonatomic, retain) IBOutlet UITextField *VariantCode;
@property (nonatomic,copy) NSString *VariantCodeToDisplay;

@property (nonatomic, retain) IBOutlet UITextField *Description;
@property (nonatomic,copy) NSString *DescriptionToDisplay;

@property (nonatomic, retain) IBOutlet UITextField *Qty;
@property (nonatomic,copy) NSString *QtyToDisplay;

in the .m file i am doing this, the code is based on the Zxing Barcode scanning scan test application.

The barcode i am scanning has a string separated by ;

- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result {
self.resultsToDisplay = result;
if (self.isViewLoaded) 
{
    //This is where the result comes back from the scanner.
    //Need to use this to add items to a basket etc
    //This is where we can create a new basket screen...

    //NSString *myString = @"This is a test";
    NSArray *myArray = [result componentsSeparatedByString:@";"];

    ItemNoToDisplay = [myArray objectAtIndex:0];
    [ItemNo setText:ItemNoToDisplay];
    [ItemNo setNeedsDisplay];

    VariantCodeToDisplay = [myArray objectAtIndex:1];
    [VariantCode setText:VariantCodeToDisplay];
    [VariantCode setNeedsDisplay];


    DescriptionToDisplay = [myArray objectAtIndex:2];
    [Description setText:DescriptionToDisplay];
    [Description setNeedsDisplay];

    [resultsView setText:resultsToDisplay];
    [resultsView setNeedsDisplay];

    }
   [self dismissModalViewControllerAnimated:NO];
}

I then have a button on the screen that the user uses to pass the data to a simple method.

-(int)AddItemToBasket:(NSString *)ItemNo:(int)QtyToAdd:(NSString *)ItemDescription:(double)SalesPrice:(NSString *)DisplayPrice;

the app runs, the user scans the code, the window gets filled in correctly, there are some fields to hold the split data.

when the use presses the button to call the method.

if i use what i expect to work

 Utility *sharedUtility = [Utility sharedUtility];

 [sharedUtility AddItemToBasket:(ItemNoToDisplay):(1):(DescriptionToDisplay):(0):(@"1")];

but this does

 Utility *sharedUtility = [Utility sharedUtility];

 [sharedUtility AddItemToBasket:(ItemNoToDisplay):(1):(Description.text):(0):(@"1")];

The first call always errors with bad access or not a NSCFstring type error.

It seems that the LAST part of the array has some funny char in it that the textfield handles, but the code does not. Some sort of termination issue.

I have worked around it by using the variable from the text box, but am confused as to why i can pass directly the value in the textfield i am passing to the text box ?

Help / Confused..

  • 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-05-25T15:35:51+00:00Added an answer on May 25, 2026 at 3:35 pm

    You are directly assigning to your string ivars instead of going through the synthesized accessors (e.g. should be self.DescriptionToDisplay = ....

    This means you are assigning an autoreleased object to the ivar, which may not be around by the time you call your AddItemToBasket method.

    As an aside, it is conventional to begin method names and ivar names with lower case letters, and also to name arguments in your methods, that AddItemToBasket method is very difficult to read.

    In answer to your comments, it may sometimes work if the area of memory has not been re-allocated since the autorelease. But you definitely need to use the accessors, particularly the setter – this will copy and increase the retain count for you. You could directly use the ivar for the getter in this situation.

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

Sidebar

Related Questions

I'm getting these errors in the console: 2010-01-07 18:15:19.036 FlagLearner[13310:207] *** -[NSCFString objectForKey:]: unrecognized
Am getting errors in this piece of code; I have placed the error messages
Am getting two errors in my model implementation file, which I have commented out.
I'm getting this error when I tried to put my array content into the
I am working with a UITableViewController. The method that fails is: - (void) testLoc
I am getting errors when trying to add items to a NSMutableArray which is
I'm getting tonnes of EXC_BAD_ACCESS errors related to the following two functions for reading
I have been working on an iPhone app that has a feature of uploading
I keep getting Clang errors on the following type of code and I can't
I have a bunch of MKPolygon saved in an array, but I wanted to

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.