AGSQueryTaskDelegate not firing - ARCGis Runtime SDK for iOS - 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.

Related

is alloc not available for my object?

I created a few custom objects, where one holds a container of the other.
The interface for ClassObject has a publicly declared init function like this:
#interface ClassObject : NSObject
#property NSDate *earliestDate;
#property NSDate *latestDate;
- (id) initWithHKQuantitySample: (HKQuantitySample *)sample;
#end
So I'd like to do the following:
ClassObject * newObject = [[ClassObject alloc] initWithClass2Object:sample];
However, I am being stopped because Xcode is not recognizing alloc as a valid selector and is only suggested alloca(size_t), which is most definitely not what I want.
What am I doing wrong?
This seems like such a basic thing, I can't figure out what I am missing or have forgotten.
Thanks for any suggestions!
If you haven't imported the header file for your custom class, it won't be recognized by Xcode. Wherever you want to use ClassObject, you should make sure you have this:
#import "ClassObject.h"
Other than that, your class looks fine to me.

use of self keyin Objective C

I am new in IOS programming.I have learnt in C++ that, 'this pointer' is used and can be accessed only inside and only for instance function(object method as in IOS ).we can't access ''this pointer'' inside the Class functions(class method in IOS ).but I have checked that I can also use them(as a self ) inside the class method in IOS. but I don't know ,May be my concept wrong or not. I have searched many sites. I have checked that,many places it is used..If 'self' can be used inside the class method ,So anyone can please tell me, How it can possible?. Is the concept of 'self' is different as 'this pointer' in C++.please explain it step by step..Thanks in advance
#import" ViewController.h"
#implementation ViewController
+(void)fun
{
[self action]; //here you can see ,Iam using 'self' for access method action.
}// but according to C++ this pointer (self)can't be used in class method.
// not giving any error...please check.
+(void)action
{
NSLog(#" Welcome in IOs world");
}
-(void)viewDidLoad{
[superviewDidLoad];
ViewController*obj=[[ViewController alloc]init];
[ViewController fun];
}
#end
In a class method self refers to the class, and in an instance method self refers to the instance of the class. So the same terminology can be used but means different things in different scopes.

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

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

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.

EXC_BAD_ACCESS using ARC only during testing

I have an issue where I'm getting bad access exceptions but only when running a testing build (calling the same methods in a debug build doesn't cause the problem to come up). The project has ARC enabled and I'm running this on the iPad 5.1 simulator using Xcode 4.3:
Here's where the problem crops up:
- (void)testChangeFoodNotification {
Player* p = [[Player alloc] init];
[p addObserver:self forKeyPath:#"food" options:0 context:0]; // <-EXC_BAD_ACCESS (code=2)
p.food += 1;
STAssertTrue(_wasNotifiedOfFoodChange, nil);
}
At the point when the addObserver: method is called it doesn't seem like any of the objects involved should have been released so what could be causing the exception?
EDIT:
Apologies if it wasn't clear but the code above is being executed as part of a test case (using the standard Xcode OCUnit). Also in case it clarifies anything here's the relevant code from the player class (there's other ivars and methods but they don't have any connection to the property or methods being tested):
// Public interface
#interface Player : NSObject
#property (nonatomic, assign) NSInteger food;
#end
// Private interface
#interface Player() {
NSInteger _food;
}
#end
#implementation Player
#synthesize food = _food;
#pragma mark - Getters/Setters
- (void)setFood:(NSInteger)food {
[self willChangeValueForKey:#"food"];
_food = food;
[self didChangeValueForKey:#"food"];
}
If your class is indeed key-value compliant, ensure that the implementation for the class exhibiting the issue is not included in your test product. This means that the Target Membership panel of the Identity inspector for your .m file should only have your app checked (not YourAppTests).
I experienced the same issue in Xcode 4.3.1 when an implementation was included in both products and I registered observers in both production and test code. The following logs tipped me off:
Class YourClass is implemented in both /Users/yourUser/Library/Application Support/iPhone Simulator/5.1/Applications//YourApp.app/YourApp and /Users/yourUser/Library/Developer/Xcode/DerivedData/YourApp-/Build/Products/Debug-iphonesimulator/YourAppTests.octest/YourAppTests. One of the two will be used. Which one is undefined.
As per the Key-Value Observing Programming Guide, is your Player key-value-compliant? You want to make sure you are Ensuring KVC Compliance. I also assume that you have also implemented your observeValueForKeyPath:ofObject:change:context:? If you think you've done all of this and it's still not working, then perhaps you can share your code.
Also, minor thing, but I assume this is a code snippet to highlight the issue. I only mention it because ARC is going to be releasing your p object at the end of your testChangeFoodNotification and I would have thought that you'd want to remove your observer first.

Resources