Closed Bmath93 closed 10 years ago
"and began incorporating this library into my project by first copying the sample code. However, whenever I try to create an OSCMessage object, Xcode throws an "unrecognized selector sent to instance" error"
- did you
#import <VVOSC/VVOSC.h>
?- please show me the sample code which is throwing this error so i can fix it!
"midway through typing this I decided to be thorough, and tried adding:
import "OSCStringAdditions.m"
to the imported files in OSCMessage.m."
i'm under the impression that importing .m files is generally considered to be bad practice. is there a specific reason you're doing this that i just don't understand/aren't aware of?
I have included #import <VVOSC/VVOSC.h>
in my .m file, but the code still crashes without #import OSCStringAdditions.m
in your OSCMessage.m file. I was aware that generally .m files aren't imported, but I'm still fairly new to app development and decided to experiment with different things to see if I could get it working.
Here's the code that sets off the error. The specific line is nearly the same as the one in the sample code, at the end where I try to create an OSCMessage.
#import "MAGTandemCanvas.h"
#import <VVOSC/VVOSC.h>
#import <VVOSC/OSCManager.h>
#import <VVOSC/OSCInPort.h>
#import <VVOSC/OSCOutPort.h>
#import <VVOSC/OSCMessage.h>
#define ADDRESS "localhost"
#define PORT 7000
#define OUTPUT_BUFFER_SIZE 1024
@implementation MAGTandemCanvas
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"viewDidLoad called");
[super viewDidLoad];
self.manager = [[OSCManager alloc] init];
[self.manager setDelegate:self];
self.outport = [self.manager createNewOutputToAddress:@"localhost" atPort:30200];
[self.manager createNewInputForPort:30200];
}
- (IBAction)backToSetup:(id)sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (IBAction)sendOSCstuff:(id)sender {
OSCMessage *newMsg = [OSCMessage createWithAddress:@"/Address/Path/1"];
[newMsg addFloat:12.34];
[self.outport sendThisMessage:newMsg];
}
@end
"Here's the code that sets off the error"
looks fine to me! does the problem go away when you add "-ObjC" to the "Other Linker Flags" section of the "Build Settings" for your iOS app?
excellent; it is now working without importing the .m file. Thank you!
I'm attempting to use this OSC library in an iOS application, and began incorporating this library into my project by first copying the sample code. However, whenever I try to create an OSCMessage object, Xcode throws an "unrecognized selector sent to instance" error. After following along in the code, it looks like somehow OSCMessage.m cannot access the methods defined for strings in OSCStringAdditions.m. I double-checked that you had remembered to import OSCStringAdditions.h (you had), and the Xcode environment seems to recognize the legitimacy of these functions by not raising an issue on the line the stringByDeletingLastAndAddingFirstSlash method is called.
midway through typing this I decided to be thorough, and tried adding:
import "OSCStringAdditions.m"
to the imported files in OSCMessage.m. For some reason, it is now working. I'm not certain why Xcode needed this, but you might want to know that this issue occurred and that the above line of code fixed it. Thanks for your library; hopefully I'll finish implementing it soon.