iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

How to get NSData of mp3 using MPMediaPickerController?

I want to upload mp3 from my phone to server, for this i am using MPMediaPickerController. After getting URL of MPMediaItem, i want to get NSData of this url , but i am getting null in NSData. – (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection { [self dismissViewControllerAnimated:YES completion:nil]; MPMediaItem *item=[[mediaItemCollection items] objectAtIndex:0]; […]

socket connection killed after iOS app goes to background

Iam using an iPhone app chat uses socket connection to communicate with the server. When the app is moved to background i can see that the server is able to communicate with the app for about 5 minutes. But after this time, the socket connection is destroyed. But the app stops executing as soon as […]

Does Cocoa Touch have a search tree data structure?

I’ve been looking into this on Google and read the Collections entry in the SDK documentation, and turned up nothing. Is there a BST (any of its variants) implementation available out of the box with the iOS SDK? It seems odd that something so basic would be missing from a major development platform. Is their […]

glReadPixels doesn't read depth buffer values on iOS

I can’t seem to read the depth buffer values in OpenGL ES2 on iOS 4.3 afDepthPixels = (float*)malloc(sizeof(float) * iScreenWidth * iScreenHeight); glReadPixels(0, 0, iScreenWidth, iScreenHeight, GL_DEPTH_COMPONENT, GL_FLOAT, afDepthPixels); My depth buffer is currently bound in place and operational, however that function reads nothing but 0 values, and it seems to return almost immediately. If […]

NSURLErrorDomain error -1012

I need to parse a xml file from a password protected URL I tried the following NSURLCredential *credential = [NSURLCredential credentialWithUser:@”admin” password:@”123456″ persistence:NSURLCredentialPersistenceForSession]; NSURLProtectionSpace *protectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@”” port:80 protocol:@”http” realm:nil authenticationMethod:NSURLAuthenticationMethodDefault]; [[NSURLCredentialStorage sharedCredentialStorage] setCredential:credential forProtectionSpace:protectionSpace]; url = [NSURL URLWithString:urlString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@”GET”]; [request setValue:@”application/xml” forHTTPHeaderField:@”Content-Type”]; connection = [[NSURLConnection alloc] […]

self.tableView reloadData not working after successful call in AFNetworking

I have a class that runs similar to the AFHTTPSessionManager component of this tutorial However, [self.tableView reloadData] is not working for me. I have the manager implemented as so: -(void) refresh{ manager = [[AFHTTPSessionManager…] iniwithBaseURL:…]; [manager Get:… parameters:… success:^(NSURLSessionDataTask *task, id responseObject){ //test success values in responseObject if(test){ //Get table data [self.tableView reloadData]; } […]

Store additional associated infomation in a UIView

I’ve been reading up a lot about Gesture Recognizers on SO – and have managed to write a working code which when a long-press is recognised on an UIImage, an action sheet appears: { … UILongPressGestureRecognizer *longPressWall = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(deleteImage:)] autorelease]; longPressWall.minimumPressDuration = 0.4; l.userInteractionEnabled=YES; [l addGestureRecognizer:longPressWall]; … } -(void)deleteImage:(UILongPressGestureRecognizer*)sender { if(UIGestureRecognizerStateBegan == […]

Resume Background Audio After Playing Sound With AVAudioPlayer

I am looking for a way to resume audio played by another application after my application plays its own sound with AVAudioPlayer. Right now, if I am listening to music and launch my application, it pauses the music, plays my sound, but doesn’t resume the background music. Here is what i’m doing to generate the […]

Getting location for an iOS app when it is in the background and even killed

My app needs to get the user’s location when app is active and when it’s inactive and killed. When the user’s location is near to a store the app has to send a local notification. I’m not sure what exactly is happening, but I’m not able to make my app get the location in the […]

How to add copyright information to a Nib file?

I’ve just finished a total re-write [1] of one of Apple’s example applications and I am going to release my code as source only on GitHub, under a BSD license. Adding the BSD license text to the .h and .m files is easy, and I can add copyright information to the .png assets that I […]