iphone-sdk-3.0

Playing sounds in iPhone SDK?

旧街凉风 提交于 2019-12-03 00:27:34
Does anyone have a snippet that uses the AudioToolBox framework that can be used to play a short sound? I would be grateful if you shared it with me and the rest of the community. Everywhere else I have looked doesn't seem to be too clear with their code. Thanks! Here is an easy example using the AVAudioPlayer: -(void)PlayClick { NSURL* musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"click" ofType:@"caf"]]; AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil]; [click play]; [click release]; } This assumes a file called "click.caf"

Keeping UINavigationController's navigationBar hidden after UISearchDisplayController selection

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 22:47:28
I have a UISearchDisplayController setup with a UITableViewController which is nested inside a UINavigationController . When a selection of a cell is made, UITableView's didSelectRowAtIndexPath method is triggered, which pushes a new view to the parent navigation controller. This new view should have the navigation bar hidden on entry. [[self navigationController] setNavigationBarHidden:YES animated:NO]; I use this line in the didSelectRowAtIndexPath method to hide the navigation bar. This works fine when a row is selected not using the search controller, but is overridden when selecting a

Load all the Contacts from iphone PhoneBook in a variable

本秂侑毒 提交于 2019-12-02 21:39:10
问题 I am naive to the xcode programming. I need to load all the contacts from the iPhone PhoneBook on a variable. Could you please suggest me some library or something like that. Any sample code would be highly appreciable. Looking forward to a response.:) Thanks in advance!!..... :) 回答1: Hey all after a long fight I found the following code working self.dataSource = [[NSMutableArray alloc]init]; // dataSouce is delared in .h file ABAddressBookRef addressBook = ABAddressBookCreate();

In-App Purchase without using iTunes Connect?

别等时光非礼了梦想. 提交于 2019-12-02 21:29:09
I have a website which sells a product to the user (downloadable). I am creating an iPhone app and want to be able to sell some of the products using the 3.0's in-app purchase. Now the documentation mentions that anything you want to sell has to be uploaded to iTunes Connect and approved by Apple. But I want to be able to keep adding products to be sold by my app on a daily basis. I have a web service to get the list of products from the website. Is it possible to include in-app purchase to let user buy this stuff from within the app but without having to add them to iTunes Connect? As I

Setting an Objective-C class property without using a self reference

China☆狼群 提交于 2019-12-02 21:20:13
This morning I ran into a crash in an iPhone app I am working on and while I fixed the bug, I'm curious about syntactic reason it was a problem. Here is my code reduced to simple elements. I am populating items in a TableView using an NSArray for the items. The NSArray is a property: @interface FooViewController : UITableViewController { NSArray *stuff; } @property (nonatomic, retain) NSArray *stuff; And in my implementation file: @synthesize stuff; - (void)viewDidLoad { NSArray *arr = [[NSArray alloc] initWithObjects:@"", @"Item 1", @"Item 2", @"Lorem", @"Ipsum", nil]; self.stuff = arr; [arr

iPhone: modifying view when user shakes

拟墨画扇 提交于 2019-12-02 19:43:47
问题 I am developing an iPhone application which deletes rows from a table view when the user shakes the phone. I have created a navigation-based project. Now when the user shakes the iPhone I want the title of the navigation bar to change to "DELETE" and a delete button to appear on the navigation bar, in the same view. Otherwise, when a user selects a particular row it should move to the next view. I have written the following code but it's not working. Please help me out. - (void)tableView:

Core Data: Reset to the initial state

Deadly 提交于 2019-12-02 19:31:36
I have an object, I make some changes to it, but I don't want to save them, I want the 'old' values. I've tried with: [managedObjectContext rollback]; [managedObjectContext redo]; [managedObjectContext reset]; and none of them seems to work ... NSLog(@"current: %@",ingredient.name); // ===> bread [ingredient setName:@"test new data"]; NSLog(@"new: %@",ingredient.name); // ===> test new data [managedObjectContext rollback]; [managedObjectContext redo]; [managedObjectContext reset]; NSLog(@"current: %@",ingredient.name); // ===> test new data // I want again ===> bread Should I refetch the

Push notification badge

你。 提交于 2019-12-02 18:26:32
问题 I am pushing several messages form my server to the iPhone. When I am pushing I'm setting the badge value as 1. As there are several independent tasks in the server there may be situational where server pushes messages to same phone but the badge will be 1 cos as those are independent tasks I cannot increment the badge and send. So I want to know whether this badge is incremented in the iPhone side or do we have to push the badge value appropriately? Thank you 回答1: The badge value will be

tablerow delete but still showon in table view

泪湿孤枕 提交于 2019-12-02 17:52:38
问题 my data is show on the table whn i select data to delet its delted from database but not from table , i go back to other view and again come to the delete table view then delete data is not show again i am using this code ... - (void)deleteRowsAtIndexPaths:(NSArray *)indexPath withRowAnimation:(UITableViewRowAnimation)animation { NSLog(@"Hello"); } -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

JSON IPHONE: How to send a JSON request and pull the data from a server?

柔情痞子 提交于 2019-12-02 17:47:50
I know barely nothing about JSON and I need to send a request to a server and read the data coming from it, using the iPhone only. I have tried to use the jason-framework to do that, but after readin the documentations I was not able to figure out how to construct the object and send it on the request. So I decided to adapted another code I saw here on SO. The Object I need is this: { "code" : xxx } Here I have a problem. This xxx is a NSData, so I suspect that I have to convert this data to a string, then use this string to build an object and send this on the request. the server response is