initWithContentsOfURL returns nil on iOS 7 on device; fine in Simulator - nsmutablearray

This ran fine before upgrading to iOS 7 and XCode 5:
NSMutableArray *test;test=[[NSMutableArray alloc] initWithContentsOfURL:[NSURL URLWithString:#"http://avia.se/iphone/gillabilen/test.xml"]];
As you can see, the URL loads fine in a browser. It validates as UTF-8. The method isn't deprecated.
It returns nil running tethered to an Iphone 4 running iOS 7. Works fine in Simulator 7.0.
I'm completely stumped here! :) Any advice appreciated.

Try this :
NSArray *a = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:#"http://avia.se/iphone/gillabilen/test.xml"]];
NSLog(#"%#", a);
Returning in my console :

Related

Controls not working with ResignFirstResponder() in release mode on iPhone 5

I have a couple of UITextFields and a UISearchBar in my app that all have a ResignFirstResponder() on it so the keyboard would go away if the user touch the done/search button on the keyboard.
Now on the iPhone 3/4 versions everything works just fine on release. But on the iPhone 5 some of the controls just don't respond when clicking on them on release. If I debug on the iPhone 5 everything works just fine but in release mode it won't work.
Anybody got any tips/solutions? Xamarin products are all from the latest version.
-- Added code
The following part of the code the iPhone 5 is going wrong.
searchProducts = UISearchBar
searchProducts.ShouldEndEditing += delegate {
searchProducts.ResignFirstResponder();
return false;
};
If I comment this part of the code everything is working just fine (only the search button on the keyboard won't work).
Fixed it to find the UITextField in UISearchBar and on that preform ResignFirstResponder.
searchProducts == UISearchBar
foreach (var item in searchProducts.Subviews)
{
if(item is UITextField){
var tf = item as UITextField;
tf.ResignFirstResponder();
}
}

sqlite3_step gives an error

I have a project created in iOS 4. But I have to move to iOS 5.1. When I run it in iOS 5.1, it gives an error in here.
`
if (sqlite3_prepare_v2(database,query_stmt, -1, &statement, NULL) == SQLITE_OK){
NSLog(#"2nd if");
while(sqlite3_step(statement) == SQLITE_ROW){
NSLog(#"error: %s\n",sqlite3_errmsg(database));`
This error message is print as unknown error
But there is a simmilar code to load a UITableView. It works without any issue. This has run on iOS 4 without any issue. Can any one help me
Thanks

Trouble in playing video from URL in iPhone using MPMoviePlayerController

I am trying to play a video through a link in my app. The code goes here
NSURL *videoURL = [NSURL URLWithString:viewURL];
NSLog(#"Filepath is: %#", viewURL);
MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(playbackFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movie];
movie.view.frame = CGRectMake(0.0f, 50.0f, 320.0f, 320.0f);
movie.fullscreen = YES;
[self.view addSubview:movie.view];
[movie play];
This was written in a method that is called on a button press. This code once worked but now there is no response from the code. Nothing happens when I click on the button even when I connected everything properly in my xib file.
Try this:
Remove
[movie play];
and add
movie.shouldAutoplay = YES;
[movie prepareToPlay];
instead.
Streaming movies (m3u8), from my experience, are a bit quirky when it comes to starting the playback. In certain situations, your original version won't work properly but my replacement always works.
EDIT:
You may also want to check your encodings and delivery using Apples Mediastream Validator as described by this Best Practice Guide and this TechNote.

How to get my phone number from iphone

I want to get my phone number. with the coding in iphone is their any way or code to get my phone number.
I am using following code for the finding of my phone number but i am getting 1(1234)12345
In simulator it is giving null value.
NSString *num = [[NSUserDefaults standardUserDefaults]stringForKey:#"SBFormattedPhoneNumber"];
Is their any other framework to include in my application.
Read this post - the following code snippet should help?
NSString *num = [[NSUserDefaults standardUserDefaults]
stringForKey:#”SBFormattedPhoneNumber”];
NSLog(#”Phone Number: %#”, num);
As I understand it, the developer license forbids access to the SIM number. The best you can do is get the number entered to activate iTunes.

Is there any sample for ALAssetsLibrary

For iPhone 4 , a lot API can not be used any more.
I am looking for alternative solution for UIImageWriteToSavedPhotosAlbum.
ALAssetsLibrary is current solution from Apple in new iOS 4.
Anyone has experience for that and can give some samples, or open source projects ?
Thanks
you need to do something like this -
ALAssetsLibrary* library=[[ALAssetsLibrary alloc] init] ;
// Request to save the image to camera roll
[library writeImageToSavedPhotosAlbum:img.CGImage orientation:(ALAssetOrientation)img.imageOrientation
completionBlock:^(NSURL* assetURL, NSError* error) {
if (error != NULL)
// Show error message...
else // No errors
// Show message image successfully saved
}] ;
Although I'm going crazy trying to figure out how to keep this code compatible with iphone 3 SDK.

Resources