cocoa-touch

How to pass a variable through a selector?

I have a method -(void)myMethod:(MyObject*)obj And I am detaching a new thread [NSThread detachNewThreadSelector:@selector(myMethod) toTarget:self withObject:nil]; How can I pass a MyObject* through @selector(myMethod)? ...

Building a complex view with Three20 - resources?

I'm using three20 for most of my iPhone app. One of the views I need to create is relatively complex. It needs a top bar (under the nav bar) with some controls and label, an image view below this bar (which occupies most of the body) and another bottom bar with more controls and labels (above the tab bar control). I don't have much UI e...

Problem with playing a sound when a button is clicked.

in my code: #import "MyViewController.h" #import "AVFoundation/AVAudioPlayer.h" - (IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExampl...

Delay in playing sounds using AVAudioPlayer

-(IBAction)playSound{ AVAudioPlayer *myExampleSound; NSString *myExamplePath = [[NSBundle mainBundle] pathForResource:@"myaudiofile" ofType:@"caf"]; myExampleSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:myExamplePath] error:NULL]; myExampleSound.delegate = self; [myExampleSound play]; } I want to play...

delete last character UITextField

Hi ! I have an UITextField and I just would like that every tap on a character, the first character is deleted. So just have one character in my textField every time. Moreover I would to to display every tap in the console log. Have you got an idea? Thanks! ...

Cocoa: AVAudioRecorder Fails to Record

AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError *err = nil; [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&err]; if(err){ NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [[err userInfo] description]); return; } [audioSession setActive:YES error:&err]; err = nil; if(err){ ...

Accessing contacts from distinct accounts in AddressBook

I'm trying to deal with the situation where a user has enabled contacts syncing from multiple sources - e.g. mobileme and an exchange account. Is there any way to distinguish to which account a contact belongs when accessing contacts through the ABAddressBook framework (or through other SDK means)? I can currently only get data for ALL (...

problem:UIScrollView doesn't refresh...

I add an UIScrollView in an UIView whose controller is UIViewController *controller1; Now, in an function of another UIViewController, I modify the UIScrollView's frame,the code is following: -(void)controller2Function { CGRect rect = CGRectMake (10,20, 100, 100); controller1.scrollview.frame = rect; } after invoke the functio...

Sorting NSArray and returning NSArray?

I am just looking at sorting an NSArray of NSNumbers into numeric order but am a little unsure of the best way to go. By my way of thinking 001 and 002 are pretty comparable, so I would suspect either will do. For 003 I am not sure if returning NSMutableArray when the method expects NSArray is good practice, it works, but it feels awkwar...

EXC_BAD_ACCESS with NSAutoReleasePool

I am detaching a new thread [NSThread detachNewThreadSelector:@selector(loadAvatar) toTarget:self withObject:nil]; I am getting an EXC_BAD_ACCESS on STObject* st = [cellitem get:@"stobject"]; In my following method -(void)loadAvatar { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; STObject* st = [cellite...

Is it possible to filter an NSArray by class?

Is there a way construct a predicate to filter by class type? I currently loop through the array and check to the class of each object. Maybe there is a cleaner way? ...

How do those bitmasks actually work?

For example, this method from NSCalendar takes a bitmask: - (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate *)date options:(NSUInteger)opts So options can be like: NSUInteger options = kCFCalendarUnitYear; or like: NSUInteger options = kCFCalendarUnitYear | kCFCalendarUnitMonth | kCFCalendarUnitDay; Wha...

Parsing Json Array of Arrays

Hi everyone, This is my first post on stackoverflow so please be patient :-) I have an Json Array of Arrays: { "response_type": "ok", "total_results": 1, "page": 1, "total_pages": 1, "sets": [ { "id": 2075184, "created": 1269989599, "term_count": 5, "has_images": false, "terms": [ ...

AccessoryDisclosureIndicator and AccessoryCheckmark on the left side

Hi I'm adding support for right-to-left languages for the UITableView. now I need to move the AccessoryDisclosureIndicator and AccessoryCheckmark from the right corner to the left. I'm taking the UIImageView path and Now I'm looking for 2 png icons: one for the AccessoryDisclosureIndicator arrow to the left and the second for the Acces...

UISearchBar Not appearing

Hi I have view controller, into the view i have put a table view, and a search bar into the table's header... the search bar is not showing up, just the empty table view. Do i need to do something additional? I'm pretty sure its to do with the view outlet of the UIViewController, set to View... Thanks ...

Create a table of contents from a pdf file

I'm using quartz to display pdf content, and I need to create a table of contents to navigate through the pdf. From reading Apple's documentation I think I am supposed to use CGPDFDocumentGetCatalog, but I can't find any examples on how to use this anywhere. Any ideas? ...

Rounded Rect UIButton without the border

I'm trying to draw a normal rounded rect UIButton, but without the border. Ideally I'd like to be able to change some setting on the UIButton to disable the border. My problem is that if I change the button type to "custom", I don't get the nice blue selection gradient (which I want to keep), and I have no idea how to draw it manually....

Using a UISearchBar search term in a web service

Hi I want to be able to use the search term from a UISearchBar as input to a web service, retrieve the results (JSON), and then display the results in the table view underneath the search bar. Is this possible / a good idea / is there a better way to achieve this? I have tried several ways, can manage to retrieve the JSON correctly, b...

UITextfield check if its a number

Hi, How can I check if a user enters a number in my UITextField. Basically its a mark im accepting between 0-100 and it can be a decimal....I heard i can try to convert it to a NSNumber type and see if it returns null. Not suree Any help would be appreciated. I have tried if(grade.text doubleValue] == 0){ //Not a number ...

How to check if variable is a CFString?

I am trying to set some text on a label descriptionLabel.text = [NSString stringWithFormat:mySTUser.bio]; The bio property of mySTUser is an NSString. Sometimes it is not an NSString when I set it. How can I check if mySTUser.bio is an NSString so I can prevent it from being assigned to my label text? ...