cocoa-touch

Global NSMutableArray doesn't seem to be holding values

I have a Cocos2D iPhone application that requires a set of CGRects overlaid on an image to detect touches within them. "Data" below is a class that holds values parsed from an XML file. "delegateEntries" is a NSMutableArray that contains several "data" objects, pulled from another NSMutableArray called "entries" that lives in the appli...

Change resolution on an image in Cocoa Touch

Hi, i need to change the resolution of an image programmatically. I'm really noobiedoobie at resolutions and Dpi so i'm not sure how to go about it. I need to change the reolution on the camera image to 300Dpi. My idea is to do the calculations in photoshop and then shrink the image by drawing it in a smaller rect with cgcontext. I's thi...

Should I re-use UI elements across view controllers?

In the iPhone app I'm currently working on, I'd like two view controllers (I'll call them A and B) to have toolbars that are identical in appearance and function. The toolbar in question will look like this: [(button) (flexible-space) (label)] For posterity's sake, the label is actually a UIBarButtonItem with a custom view. My design r...

Custom UITableViewCell won't redraw on setNeedsDisplay

I created a custom UITableViewCell class with a UIButton, a UIImage, and two UILabels. The button and the image are overlayed on top of each other, and only one is displayed at a time. The expected behavior is you touch on the button, the button disappears, and it displays the image. The UITableViewCells are set to be reused. Here's ...

iPhone OS: KVO: Why is my Observer only getting notified at applicationDidfinishLaunching

I am basically trying to implement an achievement tracking setup in my app. I have a managedObjectModel class called StatTracker to keep track of all sorts of stats and I want my Achievement tracking class to be notified when those stats change so I can check them against a value and see if the user has earned an achievement. I've tr...

How to change format of date/time?

I have this date and time format: 2010-05-19 07:53:30 and would like to change it to: Wednesday @ 7:53PM 5/19/2010 I'm doing this, which gets the current format: NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss"; but when I change the format, I end up with a null. For exa...

Performance difference in simulator and device in my game. Why ?

Hi, I am writing a small shooting game using cocos2d. It's working good in simulator. But when testing in the device, the animations of sprites are slow and they are stucking. The images I used are CCSprites. And I used CCAnimation for the animation of the images. Why the game acting different in simulator and device ? Thank you. ...

MVC - Cocoa interface - Cocoa Design pattern book

So I started reading this book: http://www.amazon.com/Cocoa-Design-Patterns-Erik-Buck/dp/0321535022 On chapter 2 it explains about the MVC design pattern and gives and example which I need some clarification to. The simple example shows a view with the following fields: hourlyRate, WorkHours, Standarthours , salary. The example is dev...

How to set the content size according to the size of UINavigation bar

Hi all I am resizing the navigation bar when my application switches into landscape orientation. But i am not able to set the content size of navigation bar according to its height. Landscape image :- In this image the top left bar item and title of navigation bar are not resizing when it switches into landscape orientation....they sh...

Cocoa API for establishing a HTTPS connection?

What is the recommended API for connecting to a HTTPS server? Ideally it should provide some way to handle the case if the server has an untrusted certificate. ...

Doesn't [UIWindow addSubView:] retain?

Check it: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSLog(@"Checking login--user value is %@", [defaults valueForKey:@"userID"]); if ([defaults valueForKey:@"userID"] == NULL){ LoginViewController *loginController = [[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil]; [window addSubview:...

Javascript in UIWebView callback to C/Objective-C

Is there a way to get a callback to objective-c when a certain event has been detected in a UIWebView? Can Javascript send a callback to Objective-C? ...

New added color in my iPhone application stop syncing it from google calendar

I am developing a application for iPhone with the syncing feature for google calendar in it.what i am doing is that ,I add some new color in my app.Now i launch the app and assign the new color to the events and sync it with google ,but the application does not sync and give error messages that color is invalid.I want to know that ,is t...

Outputing struct to NSLog for debugging?

I am just curious, is there a way to print via NSLog the contents of a struct? id <MKAnnotation> mp = [annotationView annotation]; MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance([mp coordinate], 350, 350); I am trying to output whats in [mp coordinate] for debugging. . EDIT_001: I cracked it, well unless there is a...

Instantiate UITextField delegate programatically?

I have a UITextField that has been added to my view in Interface Builder. My question is: is there a way I can programatically set its delegate from within Xcode? I know that I can connect up the delegate in IB by dragging a connection from UITextField>Delegate to my viewController which implements textFieldShouldReturn: Just curious as...

Optionally set navigationbar background image

I have the need to draw a background image or set a tint color on a navigation bar, but I also need the option to have the navigation bar appear as it normally would. I'm currently using a category to support If my app does not specify a background image, what can I do instead to ensure the drawRect method does it normally would do? I.E...

How do I reset the state of a view inside a tabbar?

Hello CocoaTouch-Experts! This is a fairly straightforward question though my Googling session gave me nothing. How do I reset the state of a view hierarchy located in a tabbar programmatically? The behavior I want to replicate is when the user tapps on a tab twice. This causes the view located under that tab to return to it's initia...

How many simultaneous (concurrent) network connections does iphone support?

I can't seem to find this anywhere, but I'm sure there must be an answer... How many simultaneous HTTP connections can an iphone app service? In other words, if I build and run a bunch of NSURLConnections asynchronously, how many can be in flight before it starts queuing them? Also, is there a method to check how many threads are avai...

Should we remove Child added by addChild method before going to next scene in cocos2d ?

Hi, I am writing a small game in cocos2d. I am adding child [ self addChild: sprite1]; Should I remove these before going to next scene by using [self removeChild: sprite1 cleanup:YES]; Does it increase the performance in device ? Thank You. ...

Properly releasing UITableViewController and UITableView directly added to a UIViewController

I have a UIViewController (parentVC) to which I add a UITableViewController as follows (it is not pushed since the tableview only occupies about half the screen): tableVC = [[SmallTableVC alloc] initWithStyle:UITableViewStylePlain]; [self.view addSubview:tableVC.tableView]; In dealloc, I add [tableVC release]; Using instrum...