Xcode7 JSONString crash.In Xocde6 not - xcode7

used JsonKit
NSDictionary *json = [result.text objectFromJSONString];
NSString *config = [json JSONString];
Run in Xcode6 is no problem, but in Xcode7 running crash

This may be not issue of Xcode. but if you run project in 64 bit device it may crash . I have the same issue.
I replaced my jsonkit by the kit provided in this link:
https://github.com/heroims/JSONKit
and the problem solved.
Thanks

Related

Too long time for converting html data in a NSAttributedString. Any ideas?

I am developing an Objective-C application for macOS. In some cases I need to convert html data to rich text using this code:
NSDictionary *htmlAttrs = nil;
NSMutableAttributedString *rtfAttributedString = [[NSMutableAttributedString alloc] initWithHTML:data documentAttributes:&htmlAttrs];
The problem is that some times, for converting the html body of a simple email, it can take up to 40 seconds, and thus this solution is not acceptable for me. I am aware that there are other questions similar to this on stack overflow, but I would like to make you notice a strange thing: at the end of the conversion process a line like this is presented in the log:
Task <A8B047AC-DABA-4259-AAF7-E2C23C84A2F1>.<0> HTTP load failed (error code: -999 [1:89])
This makes me think that NSAttributedString is probably trying to resolve some http links which are probably inexistent, so it kind of waits for a timeout (40 seconds is beyond the normal duration of the conversion so this could likely be true). If this is true, then there could be some way of telling to NSAttributedString, via the other similar methods that take more options, to not resolve links for example. Of course, I could be totally wrong. Any help is greatly appreciated. Thanks
I haven't had a chance to try this but if you use the initWithHTML:options:documentAttributes: version of the initializer, you can use the Timeout option.
NSDictionary *htmlAttrs = nil;
NSDictionary *options = #{ NSTimeoutDocumentOption: #(0.5) };
NSMutableAttributedString *rtfAttributedString = [[NSMutableAttributedString alloc] initWithHTML:htmlData options:options documentAttributes:&htmlAttrs];
The value should be a timeout in seconds.

GMSGeocoder.reverseGeocodeCoordinate throws fatal error

When I try to reverse a coordinate which is somewhere in the South Atlantic Ocean,
let geocoder = GMSGeocoder.init()
let coordinate = CLLocationCoordinate2D.init(
latitude: -33.724339999999998,
longitude: -15.996094000000001)
geocoder.reverseGeocodeCoordinate(coordinate) { (response, error) in
print(response)
})
fatal error: unexpectedly found nil while unwrapping an Optional value
Yes, I don't expect a response but it shouldn't fail with a fatal error, am I right?
Is that a normal behaviour for GMSGeocoder?
So I've experienced this weird crash as well while using reverse geocode of Google Map and since you haven't neither chosen a correct answer nor posted your own solution. I checked the production build of my app (From App Store) is working fine. I did try stashing my changes just to check what crap I did that causes this crash.
The log also states something like this:
Google Maps SDK for iOS requires GoogleMaps.bundle to be part of your target
Now for the solution, I have posted it too here: https://stackoverflow.com/a/45607775/3231194
Basically just try to update your pods and clean the project and the build, then you're good to go.
geocoder.reverseGeocodeCoordinate(coordinate) {(response, error) in
if((response?) != nil){
print(response)
}
})

How to embed html in Xcode Project for iOs8

I have been developing an iOS application - a really simple application that is based on HTML and CSS (some of them will be using PHP and my SQL) However, I have been trying to find the way to embed HTML file in my project but all the tutorials that I had found (so far) would be either for older version or there is something missing in my Xcode (like file's owner button) which doesn't make it easy or sometimes in the tutorial that I followed had something different from my current version of Xcode. (I am really new to Xcode) my Xcode version is 6.1 running on the latest version of OSx Yosemite. I might have missed something that I should know about embedding HTML file in Xcode 6 for iOS8? I would be appreciated for any answer. Thank you.
I have tried to do the same a month ago, displaying html in iOS8. My html didn't need CSS though. But I suppose the way to do it is not so different.
We can load the html file as string and that display it with an UIWebView as follows:
var filePath = NSBundle.mainBundle().pathForResource("HtmlFileName", ofType: "html")
var htmlString = NSString.stringWithContentsOfFile(filePath!, encoding: NSUTF8StringEncoding, error: nil)
var myWebView = UIWebView(frame: DeviceUtil.getScreenRect())
myWebView.loadHTMLString(htmlString, baseURL: nil)
var viewController = UIViewController()
viewController.view = myWebView
self.navigationController?.pushViewController(viewController, animated: true)

Can I store application cache of HTML5 when packaging my hybrid app?

I am developing an hybrid app.
It will bring contents from my server, and I will use application cache for performance and traffic cost issues.
Even though I use application cache, the users would have to download webpages whenever they open the pages first time.
I want to store the application cache before upload the app onto google play and apple app store.
Then, the app will only check manifest file if the page is not updated after packaging.
Can I store the application cache in the hybrid app? If then, where can I get the how-to documents, or how can I do that?
Thank you in advance!
p.s:I will package the webapp with phonegap.
Better to answer late than never, I guess!
The answer is yes, it is possible. I've got two apps in the app store that are doing this. It works reasonable well, although it's a painful process (mainly because appcache is a douche)and we're using a customised version of Cordova in order to do it.
Here's a rough idea of how you can implement this:
Have an empty local stub index.html that your Cordova startPage points at.
Implement webViewDidFinishLoad in your webview. It will do two things - open the appcache page on start and inject your cordova.ios.js into the subsequent pages. Something like this:
- (void)webViewDidFinishLoad:(UIWebView*)webView {
if(!_initialPageLoaded) {
_initialPageLoaded = YES;
NSURL *url = [NSURL URLWithString: #"https://mywebsite.com/app/"];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:ful];
[self.webView loadRequest:req];
return;
}
NSString* jsPath = [[NSBundle mainBundle] pathForResource:#"www/cordova.ios" ofType:#"js"];
NSString* c = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:nil];
[webView stringByEvaluatingJavaScriptFromString:c];
return [super webViewDidFinishLoad:webView];
}
Profit!
Note that the cordova.ios.js file is local to the application, so don't keep it on your webserver.

Xcode save html from server to plist

I have on my server a php code, when its called mydomain.com/index.php?id=11, it creates PList-format. But I must save this first on my computer via Browser(safari->save page) and must change the suffix from (.html) into (.plist), so all steps are manually. And then it used in Xcode.
How I can download direct this code by calling mydomain.com/index.php?id=11 in Xcode and save as .plist ??
Thank You!
Assuming the Plist contains an array of objects, are you able to do this?
NSURL *myURL = [NSURL URLWithString:#"http://mydomain.com/index.php?id=11"];
NSArray *myArray = [NSArray arrayWithContentsOfURL:myURL];
//either use the array as it is or save it to file:
NSString *myPath = #"some/path.plist";
[myArray writeToFile:myPath atomically:NO];
The same approach would work for a dictionary. I don't think that the suffix matters when doing this, but I haven't tried it myself.