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.










share|improve this question






















  • 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















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.










share|improve this question






















  • 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













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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 2:41









Richard Sun

82




82












  • 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


















  • 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
















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












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];





share|improve this answer





















  • 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













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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

























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];





share|improve this answer





















  • 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

















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];





share|improve this answer





















  • 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















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];





share|improve this answer












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];






share|improve this answer












share|improve this answer



share|improve this answer










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




















  • 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




















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues