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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:36:43+00:00 2026-05-26T01:36:43+00:00

I have core data configuration in my iPhone app, and how I’m currently passing

  • 0

I have core data configuration in my iPhone app, and how I’m currently passing the configuration to the view that allows a user to EDIT the data, is via passing the core data object by reference. In fact I’m allocated the core data class attribute (NSString) to the “UITextField.text” in the edit view, so that if it gets updated then it is effectively updating the core data object. The issue is:

  1. it seems to work fine when I create/update this string in the edit view
  2. when I update a separate field (not the one in question) then the value seems to be null

Question – Is there anything fundamentally wrong with this pass-by-reference approach using a core-data managed object attribute?

Code snippets:

a) In the Edit Controller – in cellForRowAtIndexPath

if (indexPath.row == 0) {
        // Setup
    UITextField *titleTextField = nil;
    // Get Cell
    self.nonWorkTermCell = [tableView dequeueReusableCellWithIdentifier:@"nonWorkTermCell"];
    if (self.nonWorkTermCell == nil) {
        self.nonWorkTermCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"nonWorkTermCell"] autorelease];
            self.nonWorkTermCell.textLabel.text = @"Non Work Term:";

            titleTextField = [[self newTextFieldForCell:self.nonWorkTermCell] autorelease];
            titleTextField.keyboardType = UIKeyboardTypeURL;
            titleTextField.returnKeyType = UIReturnKeyDone; 
        titleTextField.delegate = self;  // TODO: Is this needed at all?
        titleTextField.tag = 1;
            [self.nonWorkTermCell addSubview:titleTextField];
    }
    // Set Value
    titleTextField.text = self.weConfig.nonWorkTerm;   // ** ASSIGNS THE CORE DATA MANAGED OBJECT CONFIG ITEM DIRECTLY TO THE TEXT FIELD

        // Return 
    return self.nonWorkTermCell;

b) and the helper method it uses:

- (UITextField *)newTextFieldForCell:(UITableViewCell *)cell {
    UITextField *addTextField = [[UITextField alloc] initWithFrame:frame];  //cut the code for the frame to save space
    addTextField.autocorrectionType = UITextAutocorrectionTypeNo;
    addTextField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    addTextField.delegate = self;
    addTextField.clearButtonMode = UITextFieldViewModeNever;
    addTextField.enabled = YES;
    addTextField.returnKeyType = UIReturnKeyDone;
    addTextField.clearButtonMode = UITextFieldViewModeWhileEditing;  
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return addTextField;
}

c) then back in the delegate

- (void)applicationWillResignActive:(UIApplication *)application {
    [self saveContext];
}

- (void)applicationWillTerminate:(UIApplication *)application {
    [self saveContext];
} 
  • 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-26T01:36:44+00:00Added an answer on May 26, 2026 at 1:36 am

    Assigning a managed object’s NSString property to a textField and the editing the textfield’s content will not propagate those changes back to the managed object, for a number of reasons:

    • NSString is immutable, so by definition you won’t be making changes to the same object
    • The object returned by an accessor on managed object could well be an autoreleased copy of the underlying value
    • The textfield also probably takes a copy of whatever value is assigned to it’s text property
    • No changes will go back to the model unless they have passed through the managed object accessors which include the KVO notifications
    • The whole idea is insane. What if I wanted to take a string that I’d got from a managed object and perform some other operation on it for presentation or analysis?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.