Xcode 4.2 thread 1 sigabrt error. Retrieving from Database - sqlite

I found out that Sigabrt throws error because of this code where am trying to retrieve from database based on a tutorial but I dont know what the error is. I just commented the lines that gave me problem but am not understanding what is happening though
(void)viewDidLoad
{
MyWineLists * mywines =[[MyWineLists alloc] init];
self.wines = [mywines getMyWines];
/*[self.wineViewer setImage:((WineList *) [self.wines objectAtIndex:0]).photo];
[self.winename setText:((WineList *) [self.wines objectAtIndex:0]).wine];
[self.winerating setText:((WineList *) [self.wines objectAtIndex:0]).rating];*/
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}

Related

NSCocoaErrorDomain Code=257 when trying to access "My Photo Stream" media in iOS 13

In iOS 13, I get an error when I try to access to "My Photo Stream" media, which doesn't exist in device.
Error Domain=NSCocoaErrorDomain Code=257 "ファイル“IMG_0010.JPG”を表示するためのアクセス権がないため、開けませんでした。" UserInfo={NSFilePath=/var/mobile/Media/PhotoStreamsData/8281221100/100APPLE/IMG_0010.JPG, NSUnderlyingError=0x283452820 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
But in iOS 12 and earlier, I don't get the error.
My actual code is like below.
// asset is Photo Stream media.
PHContentEditingInputRequestOptions *editOptions = [PHContentEditingInputRequestOptions new];
editOptions.networkAccessAllowed = YES;
editOptions.progressHandler = ^void(double progress, BOOL *stop) {};
[asset requestContentEditingInputWithOptions:editOptions
completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
NSError *error;
NSData *data = [NSData dataWithContentsOfURL:contentEditingInput.fullSizeImageURL
options:(NSDataReadingMappedIfSafe)
error:&error];
NSLog(#"%#", data); // "Error Domain=NSCocoaErrorDomain Code=257"
I found some people who are struggling with similar issues.
NSCocoaErrorDomain Code=257 file couldn’t be opened because you don’t have permission to view it : FileManager attributesOfItem returns nil in iOS13
I know Apple is putting so much effort into privacy.
So anything changed around it? And I'd like to know the way to solve my problem.

Watchkit , openParentApplication with WatchKit Extension

First times doesn't work "Null"( before open App in iPhone )
and some times doesn't work but i want one loop or timer for repeat this request for get result :
here is my code
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
// Temporary fix, I hope.
// --------------------
__block UIBackgroundTaskIdentifier bogusWorkaroundTask;
bogusWorkaroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
[[UIApplication sharedApplication] endBackgroundTask:bogusWorkaroundTask];
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] endBackgroundTask:bogusWorkaroundTask];
});
// --------------------
__block UIBackgroundTaskIdentifier realBackgroundTask;
realBackgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
reply(nil);
[[UIApplication sharedApplication] endBackgroundTask:realBackgroundTask];
}];
// Kick off a network request, heavy processing work, etc.
// Return any data you need to, obviously.
// reply(nil);
reply(#{#"Confirmation" : #"Text was received."});
[[UIApplication sharedApplication] endBackgroundTask:realBackgroundTask];
// NSLog(#"User Info: %#", userInfo);
}
Watch App Code
- (void)willActivate {
// This method is called when watch view controller is about to be visible to user
[super willActivate];
NSDictionary *dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:#"MyCamande", #"OK", nil];
[InterfaceController openParentApplication:dictionary reply:^(NSDictionary *replyInfo, NSError *error) {
NSLog(#"Reply received by Watch app: %#", replyInfo);
}];
}
how can recall for get finally result
Well, I would not recommend you using anything, related to network operations on watch itself. First of all because Apple does not recommend to do it for obvious reasons. The only network thing that is performed on the watch directly is loading images.
I have been struggling with network operations and watch for like a week and came to a conclusion, that the most stable way to do it right now is not obvious.
The main issue is that WKInterfaceController.openParentApplication(...) does not work as expected. One can not just request to open iPhone app and give back the response as is. There are tons of solutions stating that creating backgound thread in - (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply would work just fine, but it actually does not. The problem is that this method has to send reply(...); right away. Even creating synchronious requests won't help, you will keep receiving "error -2 iPhone application did not reply.." like 5 times our of 10.
So, my solution is following:
You implement:
func requestUserToken() {
WKInterfaceController.openParentApplication(["request" : "token"], reply: responseParser)
}
and parse response for error that might occur if there's no response from iPhone.
On iOS side
- (void)application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply
{
__block UIBackgroundTaskIdentifier watchKitHandler;
watchKitHandler = [[UIApplication sharedApplication] beginBackgroundTaskWithName:#"backgroundTask"
expirationHandler:^{
watchKitHandler = UIBackgroundTaskInvalid;
}];
NSString *request = userInfo[#"request"];
if ([request isEqualToString:#"token"])
{
reply(#{#"token" : #"OK"});
[PSWatchNetworkOperations.shared loginUser];
}
dispatch_after( dispatch_time( DISPATCH_TIME_NOW, (int64_t)NSEC_PER_SEC * 1 ), dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
[[UIApplication sharedApplication] endBackgroundTask:watchKitHandler];
} );
}
This code just creates a background thread that forces iPhone to send a network request. Let's imagine you would have a special class in your iPhone app that would send these requests and send the answer to watch. For now, this is only accomplishable using App Groups. So you have to create an app group for your application and watchkit extension. Afterwards, I would recommend using MMWormhole in order to establish communication between your app and extension. The manual is pretty self-explaining.
Now what's the point of all this. You have to implement sending request to server and send response through wormhole. I use ReactiveCocoa, so example from my code is like this:
- (void)fetchShoppingLists
{
RACSignal *signal = [PSHTTPClient.sharedAPIClient rac_GET:#"list/my" parameters:#{#"limit":#20, #"offset":#0} resultClass:PSShoppingListsModel.class];
[signal subscribeNext:^(PSShoppingListsModel* shoppingLists) {
[self.wormHole passMessageObject:shoppingLists identifier:#"shoppingLists"];
}];
[signal subscribeError:^(NSError *error) {
[self.wormHole passMessageObject:error identifier:#"error"];
}];
}
As you see here I send back either response object, or error. Note, that all that you send through wormhole should be NSCoding-compatible.
Now on the watch you'll probably parse response like this:
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
PSWatchOperations.sharedInstance.requestUserToken()
PSWatchOperations.sharedInstance.wormhole.listenForMessageWithIdentifier("token", listener: { (messageObject) -> Void in
// parse message object here
}
})
}
So, to make a conclusion. You send request to parent application to wake up from background and start async operation. Send reply() back immediately. When you receive answer from operation send notification that you've got response. Meanwhile listen to response in your watchExtension.
Sorry, that was a lot of text, but I just hope it helps keep one's ass cool, because I've spent a lot of nerves on that.
May be you can try to explain the exact problem a little more clearly. But one thing you may want to do regardless is to make the openParentApp call in awakeWithContext: instead of willActivate.

CBCentralManager *manager EXC_BAD_ACCESS with iOS7.0

I just upgraded to Xcode V5.0 (5A1413) the build success but running the program against the emulator causes the error at the property definition:
#property (nonatomic, strong) CBCentralManager *manager; --> Thread 1:EXC_BAD_ACCESS (code=2, address=0x8)
I ran into the same issue and finally resorted to this:
UIDevice *currentDevice = [UIDevice currentDevice];
if ([currentDevice.model rangeOfString:#"Simulator"].location == NSNotFound) {
self.centralMgr = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
}
On the Simulator, if I don't guard against creation of the CBCentralManager, I see centralManagerDidUpdateState: called with a CBCentralManager* that matches my strong property. It can be referenced and the state is CBCentralManagerStateUnsupported. That makes sense, but if I nil my strong manager property at that point (since I'm not going to be doing any BLE on a simulator that doesn't support it) I get the EXC_BAD_ACCESS. So, in the absence of a better answer, I suggest you simply guard against firing up the manager at all, as in my code above.

error unrecognized selector sent to class while adding Google Map SDK to iOS6

This is a single view application and I followed the instruction given at link
https://developers.google.com/maps/documentation/ios/start
for adding google map SDK to iOS6.
ERROR Is:
unrecognized selector sent to class 0xe2b0
2013-02-07 15:21:29.788 mapApp[2061:12e03] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '+[GMSCameraPosition
cameraWithLatitude:longitude:zoom:]: unrecognized selector sent to class 0xe2b0'
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[ViewController alloc] initWithNibName:#"ViewController" bundle:nil];
self.window.rootViewController = self.viewController;
//initializing google map api key
[GMSServices provideAPIKey:#"google's api key goes here"];
[self.window makeKeyAndVisible];
return YES;
}
ViewController.m
#import "ViewController.h"
#import <GoogleMaps/GoogleMaps.h>
#interface ViewController ()
#end
#implementation ViewController
{
GMSMapView *mapView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231
longitude:77.64072579999993
zoom:6];
mapView = [GMSMapView mapWithFrame:CGRectZero camera:cam];
mapView.myLocationEnabled = YES;
GMSMarkerOptions *options = [[GMSMarkerOptions alloc]init ];
options.position = CLLocationCoordinate2DMake(13.025738,77.637809);
options.title = #"ensign";
options.snippet = #"kalyan nagar";
[mapView addMarkerWithOptions:options];
}
main.m
#import <UIKit/UIKit.h>
#import <GoogleMaps/GoogleMaps.h>
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv,nil, NSStringFromClass([AppDelegate class]));
}
}
While tracking the error it is showing at the return statement in main.m which comes from the method -viewDidLoad after executing the first line
GMSCameraPosition *cam = [GMSCameraPosition cameraWithLatitude:13.0245231
longitude:77.64072579999993
zoom:6];
It escapes the rest of the lines.
Did you add -ObjC to the Other Linker Flags, in step 7 of the instructions?
--
Extra information edit: note that -ObjC is case sensitive.
I had the same problem. Make sure you add the -ObjC flag to the 'Build Settings' of your 'Target' and NOT 'Project'.
P.S. Adding it in both places doesn't break it either.
Google Doc says
Choose your project, rather than a specific target, and open the Build Settings tab.
In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
Sometimes this is wrong....
I had to add the linker flag to the target as well, to get it to work. This should help someone

Error when calling callAPIMethodWithGET in ObjectiveFlickr

I am trying to use ObjectiveFlickr with the following sample API call but my code ends with an EXC_BAD_ACCESS. I made sure that my key and shared secret exist in flickr:
OFFlickrAPIContext *context = [[OFFlickrAPIContext alloc] initWithAPIKey:apiKey sharedSecret:sharedSecret];
OFFlickrAPIRequest *request = [[OFFlickrAPIRequest alloc] initWithAPIContext:context];
[request setDelegate:self];
[request callAPIMethodWithGET:#"flickr.photos.getRecent" arguments:[NSDictionary dictionaryWithObjectsAndKeys:#"1", #"per_page", nil]];
I had the same error, look here: ObjectiveFlickr & Xcode 4.5.2
Declare the context and request variables as properties instead, and it'll get rid of the EXC_BAD_ACCESS

Resources