3

I need to redefine one method in CGGeometry.h file (in CoreGraphics framework). You cannot do it by using Category or extension cuz it is not Objective-C class.. You will have an error.

I'm trying to redefine this function in CGGeometry.h

CG_INLINE CGRect
CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
  CGRect rect;
  rect.origin.x = x; rect.origin.y = y;
  rect.size.width = width; rect.size.height = height;
  NSLog(@"bla bla bla");
  return rect;
}

It should call my new Extended function in all over the scope of the whole project...

I can change the original source code of the CoreGraphics, but it will be related to all other projects.. I don't wont to do it that way... I'm looking for more elegant solution.

Thank you.

Avt
  • 16,927
  • 4
  • 52
  • 72
iUser
  • 43
  • 1
  • 4
  • is "`CGRectMake`" being called only in code that you own, or are there other third party or commercial frameworks that you are using? If it's all your own stuff, why not make a new method named "`iUserRectMake`" or something like that and then call ***that***? You might also try doing '`#undef CGRectMake`" and then "`#define CGRectMake iUserRectMake`" to replace it (not 100% if that would work, though). – Michael Dautermann Mar 02 '14 at 07:37
  • 2
    This is not a method, it's a function. You are trying to [interpose](http://stackoverflow.com/questions/11526882/interposing-of-os-x-system-calls), which is not as easy as overriding a method. – jscs Mar 02 '14 at 07:38
  • I am using Cocos2d. This project already exist, and now I'm trying to modify it.. There are few hundreds or thousands calls this Function CGRectMake.. I can do it by Find-Replace ... But I was wondering if there is some more correct solution ? – iUser Mar 02 '14 at 07:40

0 Answers0