Method not implemented in protocol (using wit.ai SDK) - ios

I'm using the wit.ai iOS SDK for the first time and I followed step by step what is written in the getting started page in official website https://wit.ai/docs/ios/3.1.1/quickstart. I got this error:
Method 'witDidGraspIntent:entities:body:error:' in protocol 'WitDelegate' not implemented.
I could still run the app and the message is shown in my inbox (in console) but not response is being sent back and the application crashes. I got this error:
Error when enqueuing buffer from callback
Here is my code
ViewController.m
#import "ViewController.h"
#interface ViewController ()
#end
#implementation ViewController {
UILabel *labelView;
}
- (void)witDidGraspIntent:(NSArray *)outcomes
messageId:(NSString *)messageId
customData:(id)customData
error:(NSError*)e {
//Implementation here...
labelView.text = #"Hey what's up";
[self.view addSubview:labelView];
}
ViewController.h
#import <UIKit/UIKit.h>
#import <Wit/Wit.h>
#interface ViewController : UIViewController <WitDelegate>
#end
Thanks.

Dude, the crash message you are getting is telling you exactly what is wrong.
Method 'witDidGraspIntent:entities:body:error:' in protocol
'WitDelegate' not implemented.
You are missing a method (witDidGraspIntent:entities:body:error:) in your implementation of the protocol. You must implement all the required methods in a protocol. In this case the missing method is witDidGraspIntent:entities:body:error:.
You ask "Should I add a new -void ??" By that, if you mean should you add an implementation of the witDidGraspIntent:entities:body:error: method, the answer is YES!
I haven't used the wit.ai SDK before. You might want to edit your question and ask people who have used that SDK for help in implementing the method if you can't figure out how to do it on your own. You might also want to add "(using wit.ai SDK)" to your question title so people familiar with that framework notice your question.

Related

My custom native module is not present inside NativeModules object

So, i wanted to create a native module which will detect, if the app is running on emulator/simulator or an actual device.
Everything works fine on android, but i'm facing issue on iOS.
I have create a AbcModule.h and a AbcModule.m file
#import <React/RCTBridgeModule.h>
#interface AbcModule : NSObject <RCTBridgeModule>
#end
This is AbcModule.h
#import "AbcModule.h"
#implementation AbcModule
RCT_EXPORT_MODULE(GetDetails);
- (BOOL) xyzFunctn {
#if TARGET_IPHONE_SIMULATOR
return YES;
#else
return NO;
#endif
}
RCT_EXPORT_METHOD(xyzFunctn: (RCTPromiseResolveBlock)resolve rejecter: (RCTPromiseRejectBlock)reject) {
resolve self.xyzFunctn;
}
#end
This is AbcModule.m
Here i have followed the react native documentation for implementing the Native Modules.
But i'm consistently facing this error which says
"TypeError null is not an object, evaluating GetDetails.xyzFunctn"
I have went through several solutions and articles but nothing seems to be working here.
Need help guys!
from the docs
If you do not specify a name, the JavaScript module name will match the Objective-C class name, with any "RCT" or "RK" prefixes removed.
so just do not specify any name,
#implementation AbcModule
// To export a module named AbcModule
RCT_EXPORT_MODULE();
#end
in your case it should then be accessible from within JS with
AbcModule
But the documentation is not clear if the Objective-C Class declaration needs to be written with prefixed "RCT" or "RK".. but because both prefixes seem to be valid, you should be able to just use AbcModule without prefix.
In other words, if you want to use GetDetails from within JS you need to name your interface and implementation accordingly
#implementation RCTGetDetails
RCT_EXPORT_MODULE(GetDetails);
// or
// RCT_EXPORT_MODULE();
#end
Okay, if there is someone who is facing this issue and feels like their code should work but it isn't and any solution online not working for you as well.
Try this:
When you create your .h and .m file for header and objective-c or swift file, make sure you do it in Xcode and not from VSCode.
VSCode eventually doesn't adds you .h file in the required resources folder, i have wasted my 2 weeks trying to find out solution for it, but lastly, that was it, yes this is it.
in your .m file, let's say GetDetails is a class of NSObject .swift
you need:
#interface RCT_EXTERN_MODULE(WidgetManager, NSObject)
// method to export
RCT_EXTERN_METHOD(isAuthenticated: (BOOL *)isAuthenticated)
#end
in your GetDetails.swift:
#objc(GetDetails)
class GetDetails: NSObject {
#objc(isAuthenticated:)
func isAuthenticated(_ isAuthenticated: Bool) {
}
}

How to call methods in the custom view in iOS module, from titanium project?

I need to call methods in the custom view in iOS module from titanium project. I have followed the tutorials in Appcelarator documentation about creating iOS module. I could create the custom view in Titanium using below code.
var manage = require('com.test');
var manageView = manage.createView({
left:40,
right:40,
top:40,
height: 250,
backgroundColor:'blue' }); manageView.customMethodInView();
But i got error like "customMethodInView is not a function" when i run the app.
#import "TiViewProxy.h"
#import "CustomView.h"
#interface ComTestViewProxy : TiViewProxy {
CustomView *customView;
}
- (void) customMethodInView;
#end
This is the code in viewProxy class in iOS Module project.
Please help.
I know this is late, but for any wondering soul out there, it is my understanding that even if you don't intend to pass an argument for your method, the signature of the method in the native module should always take one:
your method
- (void) customMethodInView;
should look like this :
- (void)customMethodInView:(id)unused;

implementing protocols in AppDelegate.m: "prefix attribute must be followed by an interface or protocol"

I am adding two protocols to AppDelegate so that I can swap root view controllers. I did this in a previous project (2 months ago) like so and it worked fine:
#interface AppDelegate () <ChangeRootController1, ChangeRootController2>
#end
So I did the same in today's project, but then all my functions give this error:
Missing context for method declaration
So I tried this:
#interface AppDelegate () AppDelegate <ChangeRootController1, ChangeRootController2>
#end
And now I get
Prefix attribute must be followed by an interface or protocol
What's the proper way to make AppDelegate.m conform to protocols?
Your first snippet is correct - there's nothing wrong in doing:
#interface AppDelegate () <ChangeRootController1, ChangeRootController2>
#end
I think the error is misleading you. Have you made sure to place your method declarations (e.g. of those protocols) between #implementation AppDelegate and #end?
Forget about the second code block you added there. The first one is right!
The thing that is missing is that you have some methods (probably those one required by ChangeRootController1 ChangeRootController2) outside your implementation block. Your method definitions should always be inside the implementation block of the owner class.
#interface AppDelegate () AppDelegate <ChangeRootController1, ChangeRootController2>
#end
#implementation AppDelegate
//methods go here
#end

AGSQueryTaskDelegate not firing - ARCGis Runtime SDK for iOS

I am trying to query all the features from my database through a querytask, but no delegate methods are being invoked.
#interface MyClass : NSObject <AGSQueryTaskDelegate>
I created a strong property AGSQueryTask :
#property(nonatomic, strong)AGSQueryTask* queryTask;
set the delegate as self:
self.queryTask.delegate = self;
but nothing happens.
Ideas?
I made a silly mistake, because of an uncommented line of code, my querytask got deallocated even before it could call the delegate method.

Dropbox iOS API - Simple Questions / DBRestClient Problems

EDIT:
I think I have fixed my issues. Thank you for the help - I really appreciate it.
Original Question:
I am new to objective-c and iOS programming, so hopefully my issues are not difficult to correct. I am trying to add the ability to open a file from Dropbox to my simple iOS application. I have been following the tutorial here:
http://www.mathiastauber.com/integration-of-dropbox-in-your-ios-application-making-api-calls/
I have so far successfully gotten my app to link to my Dropbox account and display the "link successful" message.
Now I am having trouble using the DBRestClient. I have the following code currently:
myviewcontroller.h
...
#end
DBRestClient *restClient;
myviewcontroller.m
- (DBRestClient *)restClient {
if (!restClient) {
restClient =
[[DBRestClient alloc] initWithSession:[DBSession sharedSession]];
restClient.delegate = self;
}
return restClient;
}
I am getting an error on the line
restClient.delegate = self;
that says
"Assigning to 'id<DBRestClientDelegate>' from incompatible type 'myviewcontroller'"
What could be going wrong? I have read through every example I can find and can see no issues with what I am trying to do.
If I try to cast by doing the following, it does not work
restClient.delegate = (id)self;
I have also found that if I remove the code in myviewcontroller.m and only have the variable declaration in the header file (as shown above) I get an error that says "Apple Mach-O Linker Error"
I would greatly appreciate any help you can provide. I am very much stuck with this problem.
In your header file you need to specify that you adhere to the DBRestClientDelegate's protocol.
For example:
#interface MyViewController: UIViewController <DBRestClientDelegate>
If you're already adhering to other protocols, simply add the DBRestClientDelegate and comma seperate, such as...
#interface MyViewController: UIViewController <UITableViewDelegate, DBRestClientDelegate>
For more information, I'd recommend a read of the Delegation section of Cocoa Core Competencies, especially as you'll be encountering delegates (and indeed perhaps defining your own protocols, etc.) a lot in Cocoa.
The error is because the right side of restClient.delegate = self; is not of type id<DBRestClientDelegate>
id<DBRestClientDelegate> is basically any object that conforms to the DBRestClientDelegate protocol
The first step (maybe only step) to removing the error is in your Myviewcontroller.h file
change
#interface Myviewcontroller : UIViewController //<-- my best guess at your interface line
to
#interface Myviewcontroller : UIViewController <DBRestClientDelegate>

Resources