263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
}
+ (IMP)replaceClassMethod: (SEL)selector
withClassMethodFromClass: (Class)class;
{
IMP newimp;
#if defined(OF_OBJFW_RUNTIME)
newimp = objc_get_class_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
newimp = method_getImplementation(class_getClassMethod(class,
selector));
#else
/* The class method is the instance method of the meta class */
|
>
>
>
>
|
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
}
+ (IMP)replaceClassMethod: (SEL)selector
withClassMethodFromClass: (Class)class;
{
IMP newimp;
if (![class isSubclassOfClass: self])
@throw [OFInvalidArgumentException newWithClass: self
selector: _cmd];
#if defined(OF_OBJFW_RUNTIME)
newimp = objc_get_class_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
newimp = method_getImplementation(class_getClassMethod(class,
selector));
#else
/* The class method is the instance method of the meta class */
|
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
#endif
}
+ (IMP)replaceInstanceMethod: (SEL)selector
withInstanceMethodFromClass: (Class)class;
{
IMP newimp;
#if defined(OF_OBJFW_RUNTIME)
newimp = objc_get_instance_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
newimp = class_getMethodImplementation(class, selector);
#else
newimp = method_get_imp(class_get_instance_method(class, selector));
|
>
>
>
>
|
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
|
#endif
}
+ (IMP)replaceInstanceMethod: (SEL)selector
withInstanceMethodFromClass: (Class)class;
{
IMP newimp;
if (![class isSubclassOfClass: self])
@throw [OFInvalidArgumentException newWithClass: self
selector: _cmd];
#if defined(OF_OBJFW_RUNTIME)
newimp = objc_get_instance_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
newimp = class_getMethodImplementation(class, selector);
#else
newimp = method_get_imp(class_get_instance_method(class, selector));
|