Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MR_SHORTHAND does not work

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'
like image 959
Matrosov Oleksandr Avatar asked Feb 24 '14 11:02

Matrosov Oleksandr


2 Answers

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'
like image 170
casademora Avatar answered Oct 11 '22 14:10

casademora


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

You have to call

[MagicalRecord enableShorthandMethods];

like image 25
Terry Lam Avatar answered Oct 11 '22 14:10

Terry Lam