I downloaded tesseract demo code of "rcarlsen-Pocket-OCR-9912da9" from https://github.com/rcarlsen/Pocket-OCR/downloads
Now i am facing problems with libraries used in it.Can anyone tell how can i solve this?or from where i can get it?
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import "ZoomableImage.h"
// conditionally import or forward declare to contain objective-c++ code to here.
#ifdef __cplusplus
#import "baseapi.h"
using namespace tesseract;
#else
#class TessBaseAPI;
#endif
#interface OCRDisplayViewController : UIViewController
<UIActionSheetDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, UIImagePickerControllerDelegate> {
TessBaseAPI *tess;
UIImage *imageForOCR;
NSString *outputString;
UIActivityIndicatorView *activityView;
IBOutlet UIBarButtonItem *cameraButton;
IBOutlet UIBarButtonItem *actionButton;
IBOutlet ZoomableImage *thumbImageView;
IBOutlet UILabel *statusLabel;
IBOutlet UITextView *outputView;
}
#property(nonatomic,retain)NSString *outputString;
#property(nonatomic,retain)IBOutlet UITextView *outputView;
#property(nonatomic,retain)IBOutlet UIBarButtonItem *cameraButton;
#property(nonatomic,retain)IBOutlet UIBarButtonItem *actionButton;
#property(nonatomic,retain)IBOutlet ZoomableImage *thumbImageView;
#property(nonatomic,retain)IBOutlet UILabel *statusLabel;
#end
I think the misstake in line (because it's cpp)
#import "baseapi.h"
try this and type semicollons manually!!!
#include "baseapi.h"
the file should be in red color.
Related
H file:
#interface TaskTypeEntity : NSManagedObject
#property (nonatomic, retain) UIColor *color;
#property (nonatomic, retain) UIImage *image;
#property (nonatomic, retain) NSString * name;
#property (nonatomic, retain) NSNumber * status;
#property (nonatomic, retain) NSSet *task;
#property (nonatomic, retain) NSSet *taskCount;
#end
M file:
#implementation TaskTypeEntity
#dynamic color;
#dynamic image;
#dynamic name;
#dynamic status;
#dynamic task;
#dynamic taskCount;
- (void) add:(TaskTypeEntity*)data
{
TaskTypeEntity *taskTypeEntity = [NSEntityDescription insertNewObjectForEntityForName:ENTITY_NAME inManagedObjectContext:content];
taskTypeEntity.name = data.name;
taskTypeEntity.image = data.image;
taskTypeEntity.color = data.color;
BOOL result = [content save:nil];
if (result) {
NSLog(#"success%#", data);
}else{
NSLog(#"fail");
}
}
#end
When setting the property, It doesn't work:
TaskTypeEntity *taskTypeEntity = [TaskTypeEntity alloc];
taskTypeEntity.name = #"dfdfd";
[taskTypeModel add:taskTypeEntity];
error:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TaskTypeEntity setName:]: unrecognized selector sent to instance 0x8a7b070'
Please help me, thank you
According to the NSManagedObject class reference:
Important: This method is the designated initializer for
NSManagedObject. You must not initialize a managed object simply by
sending it init.
The method of reference in the above quoted text is insertNewObjectForEntityForName:inManagedObjectContext: and can be used thusly:
NSManagedObject *object = [NSEntityDescription
insertNewObjectForEntityForName:#"Item"
inManagedObjectContext:context];
EDIT (In response...)
This code is just plain wrong:
TaskTypeEntity *taskTypeEntity = [TaskTypeEntity alloc];
Even if TaskTypeEntity were not a NSManagedObject it would still be wrong, as you never called an initializer.
The fact that it is a NSManagedObject makes it even more wrong, because you are never supposed to alloc/init one of those.
Why not try something like this (I assume you are using transformable attributes for image and color):
+ (instancetype)taskTypeEntityInMOC:(NSManagedObjectContext*)context
name:(NSString*)name
image:(UIImage*)image
color:(UIColor*)color
{
TaskTypeEntity *taskTypeEntity = [NSEntityDescription insertNewObjectForEntityForName:ENTITY_NAME inManagedObjectContext:content];
taskTypeEntity.name = name;
taskTypeEntity.image = image;
taskTypeEntity.color = color;
return taskTypeEntity;
}
Then you can call it...
TaskTypeEntity *taskTypeEntity =
[TaskTypeEntity taskTypeEntityInMOC:context
name:(NSString*)name
image:(UIImage*)image
color:(UIColor*)color];
I have found a tiny variant of the usual delegation pattern:
My protocol is defined in some Protocol.h, i.e,
#protocol ProtocolDelegate <NSObject>
//…
#end
//The variant, see below
typedef NSObject <ProtocolDelegate> Delegate;
Next, in my ViewController.h
#interface: UIViewController
#property (nonatomic, strong) Delegate*delegateOfviewController;
//…
#end
Then, in my ViewController.m
#implementation ViewController
#synthesize delegateOfviewController;
//…
#end
Finally, in my AppDelegate.m
//…
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//…
self.ViewController.delegateOfviewController = self;
//…
[self.window makeKeyAndVisible];
return YES;
}
And everything goes perfectly well. Is it really equivalent to the usual way " id delegate", or do you think that such a typedef should be avoided?
Thanks!
jgapc
The only difference should be whether or not you use a pointer symbol. I do not believe there is any difference, but why make a typedef when Objective-C gives you id?
Good evening,
I'm having problems with an app where a MapView is loaded when a User pushs the Bar Button on a ViewController. The MapViewController gets loaded and the Map shows correct annotations (not shown in source), but the startregion is wrong the first time the App is started and the MapView is opened. When I push the Back button once and reopen the MapView the startregion is fine. It just doesn't work for the first time.
the log gives me the correct values loaded from the plist:
47.572132 and 7.579397
Since I started coding objective-c two weeks ago, please keep your answers as simple as possible ;-)
h.File:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#import "DetailViewController.h"
#import "Annotation.h"
#interface MapViewController : UIViewController<CLLocationManagerDelegate> {
IBOutlet MKMapView *singlemapview;
}
#property (nonatomic, retain) NSArray *data;
#property int selectedBuilding;
#property (strong, nonatomic) CLLocationManager *location;
#property float longitude;
#property float latitude;
#end
m.File:
#import "MapViewController.h"
#interface MapViewController ()
#end
#implementation MapViewController
#synthesize data;
#synthesize selectedBuilding;
#synthesize location, latitude, longitude;
- (void)viewDidLoad
{
[super viewDidLoad];
NSDictionary *dataItem = [data objectAtIndex:selectedBuilding];
latitude = [[dataItem objectForKey:#"Latitude"] floatValue];
longitude = [[dataItem objectForKey:#"Longitude"] floatValue];
NSLog (#"%f",latitude);
NSLog (#"%f",longitude);
MKCoordinateRegion startregion = { {0.0, 0.0}, {0.0, 0.0} };
startregion.center.latitude = latitude;
startregion.center.longitude = longitude;
startregion.span.latitudeDelta = 0.005;
startregion.span.longitudeDelta = 0.005;
[singlemapview setMapType:MKMapTypeSatellite];
[singlemapview setZoomEnabled:YES];
[singlemapview setScrollEnabled:YES];
[singlemapview addAnnotation:singlebuilding];
[singlemapview setRegion:startregion];
}
My app had exactly the same behavior when calling setRegion method in viewDidLoad or viewWillAppear. but, calling it in viewDidAppear corrected the problem. hope this helps.
I could solve my problem now through using the -(void)viewWillAppear:(BOOL)animated function instead of using -(void)viewDidLoad
As i understand now:
ViewDidLoad is called once before a new view is opened (before the segue animation starts). But it is however still too late to draw the map correctly.
ViewDidAppear is called every time after a view did appear on the screen (after the segue animation is over).
ViewWillApper is called and calculated totally before a new view is opened (before segue animation). That's why it works properly when you have a map.
1) I have the CoreData.framework imported. In Groups & Files I see it in the Framworks list together with UIKit.framework, Foundation.framework, CoreGraphics.framework.
2) I have this code, I am not sure what this error means
#import <UIKit/UIKit.h>
#interface SQLLiteDemoAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MyTableViewController *myTableViewController; //error on this line
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#end
MyTableViewController.h looks like this
#import <UIKit/UIKit.h>
#import <CoreData/CoreData.h>
#interface MyTableViewController : UITableViewController {
NSMutableArray *names;
}
#end
MyTableViewController is not declared where you're using it so compiler can't know how to treat that name. You have 2 options how to fix that:
just import the MyTableViewController.h in your SQLLiteDemoAppDelegate.h file
use forward declaration in your header class and import SQLLiteDemoAppDelegate.h in .m file:
//SQLLiteDemoAppDelegate.h
#class MyTableViewController;
#interface SQLLiteDemoAppDelegate : NSObject <UIApplicationDelegate> {
...
//SQLLiteDemoAppDelegate.m
#import "MyTableViewController.h"
...
Have a look at
http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/ObjectiveC/Articles/ocDefiningClasses.html
the part about "Referring to Other Classes".
If the interface mentions classes not in this hierarchy, it must import them explicitly or declare them with the #class directive
In your case that would mean you have to insert
#class MyTableViewController;
before the declaration of the interface.
the problem I am trying to solve in an application that is using Core Data is to be able to hold a calculated value in a NSManagedObject custom ivar. The calculated value that I want to store is in fact an image. I do not want to persist these images; I build them and destroy them throughout the lifetime of the application. I tried along the lines of:
#interface RTStaffImage : NSManagedObject {
UIImage *image;
}
// Custom properties
#property (nonatomic, retain) UIImage *image;
// Managed object properties
#property (nonatomic, retain) NSNumber *imageID;
#property (nonatomic, retain) NSString *imageName;
and custom accessors methods:
- (void)setImage (UIImage*)im;
- (UIImage *)image;
and in the implementation:
#implementation RTStaffImage
#synthesize image;
#dynamic imageID;
#dynamic imageName;
This fails at runtime with unrecognised selector problems:
-[NSManagedObject setImage:]: unrecognized selector sent to instance
The above approach is what Apple (or, at least as far as I see having read the docs) outlines for transient properties so it should work :-(
Any ideas, comments?
- (void)setImage (UIImage*)im;
you are missing a colon between setImage and (UIImage*). This is the correct version:
- (void)setImage:(UIImage*)im;
And where are the implementations of those two methods?
-[NSManagedObject setImage:]: unrecognized selector sent to instance
just curious, I read NSManagedObject there, are you sure you create an instance of RTStaffImage there?
Yeah, you have these backwards:
#synthesize image;
#dynamic imageID;
#dynamic imageName;
You're providing an implementation for setImage and image, so image should be #dynamic, and the others you need synthesized methods for, so use #synthesize for imageID and imageName.
Good point, they should all be #dynamic since you're with CoreData.
2nd attempt: you have set RTStaffImage as the Class name in the Entity, right?
3rd attempt: is RTStaffImage.m actually part of the Target being built?