D
D
deleted-mezhevikin2013-12-19 22:16:12
Cocoa
deleted-mezhevikin, 2013-12-19 22:16:12

How to replace method in Objective-c category?

There is a MagicalRecord library.
The library has a category for the NSManagedObjectContext class ( NSManagedObjectContext+MagicalRecord.h ) it has the MR_defaultContext method.
How to replace this method with your own without getting into the library code?
I would like to update the library in the future with the help of git submodules update and do not bother to edit this method every time.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2013-12-19
@deleted-mezhevikin

I think swizzling will help here,
Here are more details: stackoverflow.com/questions/5371601/how-do-i-imple...
The only thing I'm not sure about is the categories

A
Alexey Storozhev, 2013-12-22
@storoj

You can write another category, another thing is how to make it load guaranteed later than the library one. Is it really necessary to replace this method? Will the library collapse?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question