I'm trying to use the answer accepted here: Dynamic UIMenuItems with #selector and dynamic methods
But it gives a warning (and it doesn't work) of: implicit declaration of function 'class_addMethod'
I have searched google but have no idea?
Add #include <objc/runtime.h> to the top of your implementation file (.m or .c).
Related
My project is in a Pod.
And I want to swiftify a CollectionViewCell (TVPromotionCollectionViewCell).
I just change the codes to Swift and added #import "MyProject-Swift.h" in the file which has the collectionview using TVPromotionCollectionViewCell.
But the 'MyProject-Swift.h' cannot find the BaseCollectionViewCell which is written by obj-C and I've not edited.
I read the solution of
Cannot find interface declaration in myproject-swift.h
But... I can not used the solution in my project.
I already have analytics enabled and working
i have added:
#import "FlurryAdDelegate.h"
#import "FlurryAppCircle.h"
#import "FlurryOffer.h"
#import "FlurryAnalytics.h"
this line throws this error -Use of undeclared identifier "FlurryAPI":
[FlurryAPI setAppCircleEnabled:YES];
The right call for that is [FlurryAppCircle setAppCircleEnabled:YES];
I don't think there's a FlurryAPI class at all.
See sample code at the Flurry documentation site.
Are you sure you imported the class that has FlurryAPI? Did you follow all the instructions for flurryAPI? If that was all you needed to import you most likely need to create a string (or whatever flurry uses!)
Another thing is, you could have possibly forgot to import the framework!
I have a OCR application. I'm using the tesseract api library for my app. But when i run the application, it will show the error (error: ISO C++ forbids declaration of 'TessBaseAPI' with no type?).
Here is myt.
#interface OCRViewController : UIViewController <UIImagePickerControllerDelegate,UINavigationControllerDelegate>{
UIImagePickerController *imagePickerController;
//Getting error in this line.
TessBaseAPI *tess;
UIImageView *iv;
UILabel *label;
}
You'll have to add the tesseract namespace, either with:
using namespace tesseract;
or:
tesseract::TessBaseAPI *tess;
I have tried out following solution this really works
Please rename
main.m ==> main.mm
ViewController.m ==> ViewController.mm
AppDelegate.m ==> AppDelegate.mm
This means that straight C++ style header files will no longer be included (by reference) in your plain Obj-C source.
Hope that helps, and makes sense. If this helps then please give me thumbs up.
Thanks,
I was given an static library (.a extension file) that I have to use in a project, however I need to modify some of the source code before it is useful to me. What is the best way to accomplish this?
The easy-but-most-of-the-time-not-applicable solutions are subclassing or extending.
You can also try to decompile the .a file if its licence authorizes it: cf. Decompiling Objective-C libraries, but it can be tricky and/or illegal.
You cannot modify a static library, your best bet is to try to get access to the sources or ask the author to modify it for you.
You may use a Objective C extension.
For example, there's a [MyClass myMethod] in the .a lib, and you want to change this one, the following code might be used:
#import "MyClass.h"
#interface MyClass( CategoryName )
-(void)myMethod;
#end
#implementation MyClass( CategoryName )
-(void)myMethod
{
//new implementation goes here
}
#end
You cannot modify a library, only extend. That's kind of the point - to distribute the functionality behind your code without people being able to read it.
So after an hour of research, I've found that most people seem to agree that the function at http://www.thismuchiknow.co.uk/?p=71 is the way to go for implementing a Haversine function into an iPhone project for ordering results by distance when you have a database full of latitudes and longitudes. There seems to be little help on how to actually include it in your project though, and I'm having no luck on my own.
No matter where I add the function into my ViewController.m file, I get the error expected ')' before '*' token. Some people have mentioned you need to put static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **argv); into your .h file, but I get the same error there too.
Can anyone provide a brief example of including this function in an iPhone project?
your can use this,
+(void)distanceFunc(sqlite3_context *context, int argc, sqlite3_value **argv);
or change .m extention of your viewController file to .mm.(You can try this one also)
updated
+(void)distanceFunc:(sqlite3_context *)context arg1:(int)argc arg2:(sqlite3_value **)argv;
try updated one.
Thanks,
There should be no problem with inserting the code in the link you gave anywhere in a .m file. If you are getting the error on the function definition line, it is likely that the compiler doesn't know what an sqlite3_context is. This means you haven't include the sqlite3.h header in your .m file.
Ok, so my problem was a combination of not using #import <sqlite3.h> and not adding the libsqlite3.0.dylib framework to my project. As far as where to place the function from http://www.thismuchiknow.co.uk/?p=71, I put it between my #import tags and #synthesize in my controller's .m file, appearing just as it does in the blog post.