I there any way to use objective c types for example NSRange, CGRect, etc. (they are structs) from C?
I'm using objective c runtime to access objective c classes, but some methods returns and accepts objective c types which are structs, and my problem is how to use returned objective c struct from C?
Provided that you import the correct headers, of course you can, being those plain and simple C structs. Specifically you will find NSRange defined in <Foundation/NSRange.h> and CGRect in <CoreGraphics/CGGeometry.h>.
There's nothing of Objective-C-specific in NSRange, CGRect and similar structs.
NSRange can be simple used by define:
typedef struct {
    unsigned long location;
    unsigned long length;
} NSRange;
CGRect is a little bit tricky:
struct CGRect {
   CGPoint origin;
   CGSize size;
};
typedef struct CGRect CGRect;
struct CGPoint {
   CGFloat x;
   CGFloat y;
};
typedef struct CGPoint CGPoint;
struct CGSize {
   CGFloat width;
   CGFloat height;
};
typedef struct CGSize CGSize;
typedef float CGFloat;    // 32-bit
typedef double CGFloat; // 64-bit
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With