Bridging Header Method Parameter Issue
up vote
1
down vote
favorite
I'm trying to learn how to use Bridging Headers in this test project. For this part, I want to have a method where it takes in and returns a CGPoint array.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenCVWrapper : NSObject
+ (UIImage *)grayscaleImage:(UIImage *)image;
+ (UIImage *)gaussianBlurImage:(UIImage *)image;
+ (UIImage *)cannyEdgeImage:(UIImage *)image;
//Error says Expected a type
+ ([CGPoint *])lineEdges:([CGPoint *])points;
@end
Because I'm new to this, I don't know where to even start looking for a problem.
objective-c swift bridging-header
add a comment |
up vote
1
down vote
favorite
I'm trying to learn how to use Bridging Headers in this test project. For this part, I want to have a method where it takes in and returns a CGPoint array.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenCVWrapper : NSObject
+ (UIImage *)grayscaleImage:(UIImage *)image;
+ (UIImage *)gaussianBlurImage:(UIImage *)image;
+ (UIImage *)cannyEdgeImage:(UIImage *)image;
//Error says Expected a type
+ ([CGPoint *])lineEdges:([CGPoint *])points;
@end
Because I'm new to this, I don't know where to even start looking for a problem.
objective-c swift bridging-header
Bridging header is not something you write manually. How is yourOpenCVWrapper
is defined? Swift class or Objective-C class?
– OOPer
Nov 11 at 2:52
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written thatOpenCVWrapper
is an Objective-C class in the text of your question?
– OOPer
Nov 12 at 11:50
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm trying to learn how to use Bridging Headers in this test project. For this part, I want to have a method where it takes in and returns a CGPoint array.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenCVWrapper : NSObject
+ (UIImage *)grayscaleImage:(UIImage *)image;
+ (UIImage *)gaussianBlurImage:(UIImage *)image;
+ (UIImage *)cannyEdgeImage:(UIImage *)image;
//Error says Expected a type
+ ([CGPoint *])lineEdges:([CGPoint *])points;
@end
Because I'm new to this, I don't know where to even start looking for a problem.
objective-c swift bridging-header
I'm trying to learn how to use Bridging Headers in this test project. For this part, I want to have a method where it takes in and returns a CGPoint array.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
@interface OpenCVWrapper : NSObject
+ (UIImage *)grayscaleImage:(UIImage *)image;
+ (UIImage *)gaussianBlurImage:(UIImage *)image;
+ (UIImage *)cannyEdgeImage:(UIImage *)image;
//Error says Expected a type
+ ([CGPoint *])lineEdges:([CGPoint *])points;
@end
Because I'm new to this, I don't know where to even start looking for a problem.
objective-c swift bridging-header
objective-c swift bridging-header
asked Nov 11 at 2:41
Richard Sun
82
82
Bridging header is not something you write manually. How is yourOpenCVWrapper
is defined? Swift class or Objective-C class?
– OOPer
Nov 11 at 2:52
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written thatOpenCVWrapper
is an Objective-C class in the text of your question?
– OOPer
Nov 12 at 11:50
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22
add a comment |
Bridging header is not something you write manually. How is yourOpenCVWrapper
is defined? Swift class or Objective-C class?
– OOPer
Nov 11 at 2:52
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written thatOpenCVWrapper
is an Objective-C class in the text of your question?
– OOPer
Nov 12 at 11:50
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22
Bridging header is not something you write manually. How is your
OpenCVWrapper
is defined? Swift class or Objective-C class?– OOPer
Nov 11 at 2:52
Bridging header is not something you write manually. How is your
OpenCVWrapper
is defined? Swift class or Objective-C class?– OOPer
Nov 11 at 2:52
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written that
OpenCVWrapper
is an Objective-C class in the text of your question?– OOPer
Nov 12 at 11:50
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written that
OpenCVWrapper
is an Objective-C class in the text of your question?– OOPer
Nov 12 at 11:50
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Since you need to return an array of CGPoint, your array should hold a NSValue type, because the array cannot hold struct type
+ (NSArray<NSValue *> *)lineEdges:(NSArray<NSValue *> *)points;
and you should call your method as
NSArray *lineEdges = [OpenCVWrapper lineEdges:@[[NSValue valueWithCGPoint:CGPointMake(3.3, 4.4)]]];
The return value also should be in NSValue and extracting
NSValue *val = [lineEdges objectAtIndex:0];
CGPoint p = [val CGPointValue];
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Since you need to return an array of CGPoint, your array should hold a NSValue type, because the array cannot hold struct type
+ (NSArray<NSValue *> *)lineEdges:(NSArray<NSValue *> *)points;
and you should call your method as
NSArray *lineEdges = [OpenCVWrapper lineEdges:@[[NSValue valueWithCGPoint:CGPointMake(3.3, 4.4)]]];
The return value also should be in NSValue and extracting
NSValue *val = [lineEdges objectAtIndex:0];
CGPoint p = [val CGPointValue];
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
add a comment |
up vote
0
down vote
accepted
Since you need to return an array of CGPoint, your array should hold a NSValue type, because the array cannot hold struct type
+ (NSArray<NSValue *> *)lineEdges:(NSArray<NSValue *> *)points;
and you should call your method as
NSArray *lineEdges = [OpenCVWrapper lineEdges:@[[NSValue valueWithCGPoint:CGPointMake(3.3, 4.4)]]];
The return value also should be in NSValue and extracting
NSValue *val = [lineEdges objectAtIndex:0];
CGPoint p = [val CGPointValue];
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Since you need to return an array of CGPoint, your array should hold a NSValue type, because the array cannot hold struct type
+ (NSArray<NSValue *> *)lineEdges:(NSArray<NSValue *> *)points;
and you should call your method as
NSArray *lineEdges = [OpenCVWrapper lineEdges:@[[NSValue valueWithCGPoint:CGPointMake(3.3, 4.4)]]];
The return value also should be in NSValue and extracting
NSValue *val = [lineEdges objectAtIndex:0];
CGPoint p = [val CGPointValue];
Since you need to return an array of CGPoint, your array should hold a NSValue type, because the array cannot hold struct type
+ (NSArray<NSValue *> *)lineEdges:(NSArray<NSValue *> *)points;
and you should call your method as
NSArray *lineEdges = [OpenCVWrapper lineEdges:@[[NSValue valueWithCGPoint:CGPointMake(3.3, 4.4)]]];
The return value also should be in NSValue and extracting
NSValue *val = [lineEdges objectAtIndex:0];
CGPoint p = [val CGPointValue];
answered Nov 11 at 18:32
cool_jb
345
345
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
add a comment |
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Thank you, this works perfectly. Also, I've been seeing the asterisk symbol a lot in some sample code. I've read that its a pointer, whose value is actually a reference to a location. Is this correct?
– Richard Sun
Nov 12 at 1:48
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
Yes thats correct. For more details on pointers you can go through this stackoverflow.com/questions/897366/…. Also please mark the answer as accepted, so that it may help others identify the right working solution
– cool_jb
Nov 12 at 4:38
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53245390%2fbridging-header-method-parameter-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Bridging header is not something you write manually. How is your
OpenCVWrapper
is defined? Swift class or Objective-C class?– OOPer
Nov 11 at 2:52
Sorry, I'm not sure I understand your question (I'm still new to this). I think that OpenCVWrapper is an Objective-C interface. I'm using the OpenCV framework, which I believe is in c++.
– Richard Sun
Nov 12 at 1:43
You write Objective-C interface in combination with Objective-C implementation. The interface is needed to write the implementation, not for the bridging header. Or else when you write a Swift class, Xcode generates a bridging header. Have you written that
OpenCVWrapper
is an Objective-C class in the text of your question?– OOPer
Nov 12 at 11:50
Yes, I understand what you mean. OpenCVWrapper is an Objective-C class
– Richard Sun
Nov 13 at 21:22