iphone

openURL: with a NSURL containing a formatted NSString isn't working

To open Google Maps with directions, i'm using a formatted NSString inside a NSURL. But it doesn't work with [[UIApplication sharedApplication] openURL:nsurl]; code: NSString * directionsURL = [NSString stringWithFormat:@"http://maps.google.com/maps?daddr=%@&saddr=%@", @"Hartenseweg 16, Renkum", @"1 Infinte Loop, Cupertino"]; [...

OCMock on a method with argument and returns a value

I have a class that relies on NSUserDefaults that I'm trying to unit-test and I'm providing the NSUserDefaults as a mock into my test class. When running the test, I get the error: OCMockObject[NSUserDefaults]: unexpected method invoked: dictionaryForKey:@"response" I'm trying to mock this instance method of the NSUserDefaults ...

UIPicker crashes app if i spin one component at the same time as another

Hi All I have a picker with three components. The first two components are dependent on the last. So it could be: | 5 | M (The lines represent the different columns) or 1" | 5" | FT If I am moving the second or first column and before they stop spinning I move the third column from from FT to M or visa versa and then while ...

How to customize UITableViewCell for string length

I have to fit strings within a table. The strings are of different lengths. The cell of the table should be sized according to string length. I am using sizeWithFont:constrainedToSize: . But I could not use it properly. Can any one please suggest a solution? ...

Using CALayer Delegate

I have a UIView whose layers will have sublayers. I'd like to assign delegates for each of those sublayers, so the delegate method can tell the layer what to draw. My question is: What should I provide as CALayer's delegate? The documentation says not to use the UIView the layers reside in, as this is reserved for the main CALayer of...

iPhone: "unrecognized selector sent to instance"

I try to set two different views into a subview, according to the state of a SegmentSwitcher: if ([sender selectedSegmentIndex] == gameIndex) { if (self.gameView.view == nil) { GameView *gameV = [[UIViewController alloc] initWithNibName:@"GameView" bundle:nil]; self.gameView = gameV; [gameV release]; } ...

How do you prompt the user to rate your iphone app without waiting for them to delete the app?

I am referring to the popup window that asks the user to submit a review/rating. I know it can be done since the Aardark app does it...it asks several times in fact! (Almost too spammy.) But there has to be an API to trigger the rating request? Google is giving me no love on this one. ...

Displaying bold text from SQLite in UITableViewCell

We're storing text in SQLite and displaying it in UITableViewCell within our iPhone application. UITableViewCell seems to recognize line breaks from SQLite, but not bold text. Any suggestions would be much appreciated. ...

Help setting up a data model in Core Data

Hi, I am new to Core Data, and have been trying to figure out how to set up my data model. I made a sample table to try and show how I need the data to relate. First Name Last Name Competitor Number Gender Team Competition Game Name All Time high Competition Scores Jon Doe 1 M Gamers January Don...

NSAssert usage in threads

I'm trying to use NSAssert throughout my iPhone app so that if an unexpected condition occurs, the application fails-fast and crashes with a meaningful message in the crash log. This works fine if the failing NSAssert is on the main thread, as it raises NSInternalInconsistencyException by default which is uncaught and stops execution. B...

iPhone - Problems with UITableView - reload data & no hits

Hello! I am using this example of Apple's sample code: http://developer.apple.com/iPhone/library/samplecode/TableSearch/index.html In this example the UITableView get a list of content at startup. Clicking in the UISearchBar and typing, the content list will be filtered, also checking on scope of the ScopeBar. I have to rebuild this ...

Iphone I am using cocos2d and need the rgba value of a pixel on a sprite

I am programing a shooter game in cocos2d for the iphone. I and I want to exclude collision detection an the alpha of my sprite. How do I read the RGBA value of the single pixel. Thanks for the help. ...

Change color of NavigationBar for the "More" tab?

When you have more than 5 view controller in your TabBarController, a "More" view is automatically setup for you. Is it possible to change color of the navigationBar in this view to match the color I am using, instead of the default blue? ...

How do I choose a video from UIImagePickerController on iPhone 3G?

On my iPhone 3G I have a couple videos saved from emails and some apps i recored with and every time I try and open the UIImagePickerController it doesn't show the videos for me to choose. How do I get the UIImagePickerController to include videos and not just pictures? ...

Custom UITableViewCell rounded corners (grouped style)

When creating a custom UITableViewCell I notice that it looks as expected in 'plain' style but that the corners of the cells are not rounded if the table view is displayed in 'grouped' style: i.e. the corners are square. I have searched but cannot find any real explanation of why this happens and, more importantly, how to remedy this ef...

Set "opacity" of a CGLayer before draw?

I have UIView subclass - actually a puzzle piece - with 2 different CGLayer initialized at initWithFrame. In drawRect I have to blend this two layer, and the uppermost should have variable alpha depending on game-logic. What is the best (most performance optimized) way to do this? Is there any CGLayer, or CGContext function that sets s...

Add both UIBarButtonSystemItemAdd and UIBarButtonSystemItemTrash to one side of a Navigation Item or a UISegmentedControl

Hi there, Well, the title says it all. I'd like to have a UIViewController which has an Add and a Trash button both right to the title, either by adding two UIBarButtonItems to the navigation item/bar or by adding them to a UISegmentedControl and then adding the SegmentedControl to the item. Is this possible? If yes, how is it achieved ...

How to make Action Sheet button open new view

I have an iPhone app that uses an action sheet but I can't work out how to make one of the buttons open a new view when pressed. I know how to implement the action sheet - that's not a problem, its the actual action of opening the new view that's the issue. Any help would be greatly appreciated. Thanks. ...

answer to my old question about navigation Controller !

hi guys . i had questioned here : http://stackoverflow.com/questions/1675113/best-idea-for-importing-text-to-each-navigationcontroller-view the answer was this: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { PoemDetailsViewController *poemDetails = [[[PoemDetailsViewController alloc...

How should I handle a failure in an init: method in Objective-C?

Let's say I'm building a new class for the iPhone in Objective-C. In one of my init methods I want to manually allocate some memory. So, I might have something like this: - (id)initWithSomeObject:(SomeObject *)someObject { self = [super init]; if (self != nil) { myObject = someObject; [myObject retain]; if ( (memory = ...