MR_SHORTHAND does not work
Asked Answered
P

3

5

I use MagicalRecords but by some reason MR_SHORTHAND does not work for me.

I have added these lines below to Prefix.pch

#define MR_SHORTHAND
#import "CoreData+MagicalRecord.h"

In case when app calls + createEntity method the app terminates due unrecognized selector. But if I write MR_createEntity everything works fine.

Team *team = [Team MR_createEntity]; // This line works

but

Team *team = [Team createEntity]; // This line does not work

with reason: '+[Team createEntity]: unrecognized selector sent to class 0x74b8c'
Poulenc answered 24/2, 2014 at 11:2 Comment(0)
A
21

I know we haven't announced it publicly prior to this answer, but we've decided to deprecate shorthand support, and remove it in the upcoming MR3 release.

Shorthand support is an interesting idea and feature, but it is not something we want to maintain. We would rather focus our efforts on getting the data centric part of MagicalRecord to be as solid and reusable as possible.

That said, you're certainly welcome to fix it yourself and submit a patch to the older branch of MagicalRecord. Some things to look at are:

  • Make sure the shorthand selectors are included, and add new ones if they are not present
  • Make sure you've used the MagicalRecord class once prior to this call. All the shorthand support is initialized in the class initializer method.
  • If you're using Cocoapods, you may need to update your pod spec reference to 'MagicalRecord/Shorthand'
Acis answered 24/2, 2014 at 11:49 Comment(1)
Ok thank you for the answer ) The MagicalRecords the best thing ever ) in any casePoulenc
W
2

According to the official guide https://github.com/magicalpanda/MagicalRecord/blob/master/Docs/Installing-MagicalRecord.md

You have to call

[MagicalRecord enableShorthandMethods];

Waterfall answered 10/6, 2015 at 8:56 Comment(0)
M
-2

the above error means the core data stack is not initialized yet. you should add [MagicalRecord setupCoreDataStackWithStoreNamed:dbName]; in app delegate before [self.window makeKeyAndVisible];

because if you have called [Team createEntity]; in your root VC [self.window makeKeyAndVisible]; make the view be loaded and visible, but still app has not reached the next line to setup core data stack

Maraud answered 13/2, 2015 at 19:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.