Tag: iphone

loading images from a background thread using blocks

I have the following method, which basically calls a request to load an array of NSData of images in the background thread: [query findObjectsInBackgroundWithBlock:^(NSArray * objects, NSError * error){ }]; In this case objects is an array of the NSData. The issue is that if I have 100 images to load (100 elements in the […]

UIImage from CALayer – iPhone SDK

In my application, I have created a CALayer (with a few sublayers – the CALayer is composed of shapes added as sublayers). I am trying to create a UIImage that I will be able to upload to a server (I have the code for this). However, I can’t figure out how to add the CALayer […]

Sound not working in iPhone Simulator?

Somehow my iPhone Simulator is unable to play sounds. First an app I’m working on using AudioServicesPlaySystemSound() stopped working.. I spent a while debugging this but sound is still working on the iPhone when I run the app on the device. I get the same results with other iPhone apps such as the sample Crash […]

Keeping object on top of keyboard in the event of becomeFirstResponder or resignFirstResponder?

I currently have a UITextField on top of a keyboard. When you tap it, it should stick on top of the keyboard and move up smoothly. I don’t know the exact duration and animation type of the keyboard, so it’s really bumpy. Here’s what I have: [theTextView resignFirstResponder]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:0.25]; […]

Reading audio samples via AVAssetReader

How do you read audio samples via AVAssetReader? I’ve found examples of duplicating or mixing using AVAssetReader, but those loops are always controlled by the AVAssetWriter loop. Is it possible just to create an AVAssetReader and read through it, getting each sample and throwing the int32 of each audio sample into an array? Thanks.

Pre-buffering for AVQueuePlayer

Does anyone know if AVQueuePlayer starts buffering the next AVPlayerItem when the current item is about to finish playing? I know there’s nothing in the docs to suggest this, I’m asking mostly if anyone has observed this kind of behavior or not.

How to add a UIView above the current UITableViewController

I have difficulty adding a subview (UIView) from within the viewDidLoad method of a UITableViewController This works: [self.view addSubview:self.progView]; But you can see the table cell lines bleed through the UIView progView. I’ve tried this approach: [self.view.superview insertSubview:self.progView aboveSubview:self.view]; Which is an attempt to add the progView, UIView to the superview, above the current view. […]

iPhone Store Kit “Cannot connect to iTunes Store”

I am working on adding In-App purchases to my app. I am able to receive the productsRequest:didReceiveResponse method, and receive the array of products. My problem arises when I add a SKPayment to the SKPaymentQueue. After I add the product to the queue, in the paymentQueue:updatedTransactions method the transactions always have the state SKPaymentTransactionStateFailed. I […]

Encode NSString for XML/HTML

Is there a way to HTML encode a string (NSString) in objective-c, something along the lines of Server.HtmlEncode in .NET? Thanks!

Best way to save data on the iPhone

I am writing an iPhone application, and need to save the state of my application (5K or so). My main worry is data persisting across upgrades. Some of the applications I use clearly got this wrong, and I would prefer not to!