struct Line {
NSUInteger x1;
NSUInteger x2;
};
// ...
- (Line)visibleLine;
The code above obviously doesn't work because Line is not a valid type. Any suggestions?
Objective-C is a based on C not C++. In C
we need to use struct Line
, while in C++ Line
is fine.
You can do this as :
struct {
NSUInteger x1;
NSUInteger x2;
} Line;
// ...
- (struct Line)visibleLine{
}
OR
struct Line {
NSUInteger x1;
NSUInteger x2;
};
typedef struct Line Line;
// ...
- (Line)visibleLine;
Above is preferred by most C frameworks.
Also,
typedef struct {
NSUInteger x1;
NSUInteger x2;
} Line;
// ...
- (Line)visibleLine;
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