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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:39:53+00:00 2026-05-13T15:39:53+00:00

I have several core data entities that contains a bunch of empty NSString properties.

  • 0

I have several core data entities that contains a bunch of empty NSString properties.

I parse some XML and set the properties I can get a hold of and would like to set the “empty” ones to “n/a” as in “not available”. So if my XML does not contain the values it sort of tidy up the Entity by giving it a “n/a” string I can test for later on, also should one of these make it to a UILabel it will not display (null) .. which leads me to my question:

I do this to test if the property on the Entity is already sat, is nil or is empty:

    for(NSString *s in allPossibleStrings) {

        if([[f valueForKey:s] isKindOfClass:[NSString class]] && [[f valueForKey:s] isEqualToString:@""]) {
            [f setValue:@"n/a" forKey:s];
        }
        if ([[f valueForKey:s] isKindOfClass:[NSString class]] && [f valueForKey:s] == nil) {
            [f setValue:@"n/a" forKey:s];               
        }
    }

It turns out however that I still end up with a lot of values being displayed as (null).
So I was thinking can the property be something else than @"" empty or (nil)

I believe the NSManagedObject should be KVC compliant so I did a test where I copied my NSManagedObject property by property, only difference is that is is a subclass of just NSObject instead of NSManagedObject.
Sadly this behaves in the exact same way. It also leaves values as (null)

Hope someone can pick up on where I go wrong with these string tests 🙂

Thank You

  • 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-13T15:39:53+00:00Added an answer on May 13, 2026 at 3:39 pm

    You could set the default property value of your entity to “N/A” (that’s a good practice, because you might want to use sqlite for iPhone app shipping, and it doesn’t work well with null values because sqlite and cocoa don’t have the same vision of “null”) and set “optional” to “No”.

     if([[f valueForKey:s] isKindOfClass:[NSString class]] && [[f valueForKey:s] isEqualToString:@"NA"]) {
           //Tell your program to know that it's null if it needs to know
        }
    

    Cheers

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

Sidebar

Related Questions

I have a core data based app that manages a bunch of entities. I'm
I have set up a Core Data model that includes an entity, Item with
I have a long running query that returns a large data set. This query
I have a question in core data: there are 2 Entities in the project,
Sometimes we have several classes that have some methods with the same signature, but
I have several RequiredFieldValidators in an ASP.NET 1.1 web application that are firing on
I have several tables whose only unique data is a uniqueidentifier (a Guid) column.
We have several jobs that run concurrently that have to use the same config
I have several old 3.5in floppy disks that I would like to backup. My
I have several applications that are part of a suite of tools that various

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.