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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:07:16+00:00 2026-06-12T02:07:16+00:00

I use Core Data and have an object ExerciseForRoutine . I’m currently manually creating

  • 0

I use Core Data and have an object ExerciseForRoutine. I’m currently manually creating it and then settings it’s attributes, which seems to waste code. Is there any way I can create a custom init method to handle this in one line (I know how to do around alloc/init, but core data has a different init method..)

Current Code:

ExerciseForRoutine *exerciseForRoutine = (ExerciseForRoutine *)[NSEntityDescription insertNewObjectForEntityForName:@"ExerciseForRoutine" inManagedObjectContext:managedObjectContext];
exerciseForRoutine.name = self.selectedExercise;
exerciseForRoutine.timeStamp = date;
exerciseForRoutine.muscleGroup = self.muscleName;
exerciseForRoutine.musclePicture = self.muscleURL;

ExerciseForRoutine Class

@class Routine;

@interface ExerciseForRoutine : NSManagedObject {
@private
}
@property (nonatomic, strong) NSDate * timeStamp;
@property (nonatomic, strong) NSString * name;
@property (nonatomic, strong) NSString * muscleGroup;
@property (nonatomic, strong) NSString * musclePicture;
@property (nonatomic, strong) Routine * exerciseToRoutine;

@end

@implementation ExerciseForRoutine
@dynamic timeStamp;
@dynamic name;
@dynamic muscleGroup;
@dynamic musclePicture;
@dynamic exerciseToRoutine;
  • 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-12T02:07:17+00:00Added an answer on June 12, 2026 at 2:07 am

    The classes which Xcode creates for handling core data objects should not be overridden, instead what you could do is create your own custom class which inherits from NSObject and write your methods to handle the managed object their.

    Sol: You can do this with the help of the parameterized init method

    Then it would look something like this

    CoreDataHelperClass *someobj = [[CoreDataHelperClass alloc]initWithname:@"name" andTimeStamp:@"Time" andMuscleGroup:@"musclegroup" andPicture:UIImagePNGRepresentation(someimageObj)];
    

    To do the above you need to add your own init method in the CoreDataHelperClass class like this

    .h part of CoreDataHelperClass

    
    - (id)initWithName:(NSString*)name andTimeStamp:(NSString*)timeStamp andMuscleGroup:(NSString*)group andPicture:(NSData*)imageData;
    
    

    .m part of CoreDataHelperClass

    
    - (id)initWithName:(NSString*)name andTimeStamp:(NSString*)timeStamp andMuscleGroup:(NSString*)group andPicture:(NSData*)imageData
    {
    
    //you assignment code to the core data attributes goes here
    
    ExerciseForRoutine *obj = [[ExerciseForRoutine alloc]init];
    
    obj.name = name;
    obj.timestamp = timeStamp;
    
    //and so on
    
    return self;
    
    }
    
    
    

    Anyways what you could also do is pass a dictionary with the keyvalue pair get the values in your custom class or you may also pass an NSMutableArray like what ever suits your business model both will work.

    You can get the values of Dictionary or Array inside your CoreDataHelperClass and assign those values to your attribute.

    Hope i have got your query right if not then kindly mention the error part via comments

    • 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 object and a REST web interface that use different
Previously, I have an app that uses core data. I use same store url
I am doing a project which involves a good use of core data. I
I have a core data model object called Entry. In this I have an
I'm currently trying to create my Core Data object graph with an xml file.
I have a complex iPad app moving to use Core Data. I receive data
I have an attribute in a Core Data Managed Object that I'm trying to
I'm using Core Data and i have a managed object that the description states
I'm currently learning to use Core Data on iOS , in my test application
I have an entity Tag (in core data) that have some attributes and a

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.