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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:19:31+00:00 2026-05-28T18:19:31+00:00

I keep running into this exception when trying to set my property phoneNumber: *

  • 0

I keep running into this exception when trying to set my property “phoneNumber”:

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘- [SearchResult setPhoneNumber:]: unrecognized selector sent to instance 0x256b40’

Here’s the class with the phoneNumber property:

@interface SearchResult : NSManagedObject
@property (nonatomic, retain) NSString * phoneNumber;
@end

@implementation SearchResult
@dynamic phoneNumber;
@end

Issue is that when I do this:

SearchResult *managedObject = [self findExistingSearchResultById:restaurantId];

if(managedObject == nil)
{ 
    managedObject = [NSEntityDescription insertNewObjectForEntityForName:@"SearchResult" inManagedObjectContext:managedObjectContext];
}

// Exception throws here.
managedObject.phoneNumber = @"1234567890";

Here’s the findExistingSearchResult method:

+ (SearchResult *)findExistingSearchResultById:(NSString *)restaurantId
{
    NSManagedObjectContext *managedObjectContext = serviceContext;
    NSFetchRequest *request = [[NSFetchRequest alloc]init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"SearchResult" inManagedObjectContext:managedObjectContext];
    [request setEntity:entity];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"restaurantId = %@", restaurantId];
    [request setPredicate:predicate];

    NSError *error = nil;
    NSArray *fetchedObjects = [managedObjectContext executeFetchRequest:request error:&error];
    if(fetchedObjects != nil)
    {
        return [fetchedObjects lastObject];
    }
    else
    {
        return nil;
    }
}

I’m using very similar class implementations across my app, and not running into any issues like this. I haven’t figured out why setting phoneNumber property here throws this exception.

  • 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-28T18:19:32+00:00Added an answer on May 28, 2026 at 6:19 pm

    The problem is that you are trying to instantiate a NSManagedObject using a conventional alloc/init method of NSObject.

    If you want to use CoreData you have to use the NSManagedObject designated initialiser, as described on the class reference documentation for NSManagedObject

    NSManagedObject is a generic class that implements all the basic
    behavior required of a Core Data model object. It is not possible to
    use instances of direct subclasses of NSObject (or any other class not
    inheriting from NSManagedObject) with a managed object context. You
    may create custom subclasses of NSManagedObject, although this is not
    always required. If no custom logic is needed, a complete object graph
    can be formed with NSManagedObject instances.

    A managed object is associated with an entity description (an instance
    of NSEntityDescription) that provides metadata about the object
    (including the name of the entity that the object represents and the
    names of its attributes and relationships) and with a managed object
    context that tracks changes to the object graph. It is important that
    a managed object is properly configured for use with Core Data. If you
    instantiate a managed object directly, you must call the designated
    initializer (initWithEntity:insertIntoManagedObjectContext:).

    Source: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html

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

Sidebar

Related Questions

im trying to fix this while loop but keep running into errors. Basically lets
I keep running into this design problem, and I'm not happy with my solution
I keep running into this error MemCacheError (Broken pipe): Broken pipe on my Rails
I'm trying to work through the problems on projecteuler.net but I keep running into
I keep running into this problem over and over. I have a view with
I keep running into this issue: class CCreateShortcutTask : public CTask { public: CCreateShortcutTask(
I keep running into this. I want to spawn processes and pass arguments to
TypeError: Result of expression 'this._configure' [undefined] is not a function. I keep running into
This is a design issue I keep running into, so I thought I would
So, I'm trying to install gcc for SimpleScalar-3.0, and I keep running into trouble

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.