objective-c

How to structure a very large Objective-C class?

Hi, I've a fairly complex window that is backed by a controller class that is obviously growing to meet the needs of my view window. While I believe I am sticking to proper MVC I'm still having problems managing a fairly largish controller class. How do you breakdown your objects? Maybe use Categories? For example, one category to hand...

UIImageView rotate and resize

Hello guys! I want to rotate my UIImageView and set the size according to the aspect ratio. But I have some problems with that. First I paste here my code, then I explain the problem. imageView.size = CGSizeMake(myWidth, myHeight); [imageView setContentMode:UIViewContentModeCenter]; So these two lines set the size and the contentMode...

Origin of Rectangle in CGMakeRect

I have a simple screen in my iPhone app where I want a rectangle of 320x100 at the bottom of the screen to capture a touch. Here is my code inside touchesBegan:withEvent: for (UITouch *touch in touches) { CGPoint touchPoint = [touch locationInView:self.view]; NSLog(@"touch @ %f, %f", touchPoint.x, touchPoint.y); // build...

Message without dot notation?

Quick question, could anyone help me out with regards to writing this without dot notation? (i.e. [self setView? ...) self.view.transform = CGAffineTransformIdentity; many thanks, gary ...

objective c iphone integers

Is it true to say that when using integers when programming for iphone that you do not synthesize them and that you do not release them. If it is true could somebody explain why? I get errors everytime that I try to. Also if I set an @property for an integer value I too get errors ...

Unable to open database SQLITE iPhone

Hi there, I am using SQLITE database in my iPhone app. I have a refresh button on my home screen and on click of that refresh button I usually fetch the data from my web service and store it into my database. In normal scenario it works fine but when I click my refresh button 4-5 times frequently my app crashes and My app log Shows "Unab...

+ (void) initialize not called (Objective C)

Guys, My method + (void) initialized is not called and I'm very new in Objective C. The code is in the book iPhone Game Development and I have to call the method explicitly to work. The code in the .m file is that: ResourceManager *g_ResManager; @implementation ResourceManager //initialize is called automatically before the class ge...

UITableView scroll to where user clicked

Hi I am sure this a pretty common problem: I have a UITableView with quite some entries in it. If you click on a cell, you get to see some details about the selected object (done with a navigation controller). Now if the user hits the back arrow at the top of the screen, he successfully returns to the old table, but this is now scrolled...

Deselect UIButton on touch down outside

I have a UIButton that selects itself on UIControlEventTouchUpInside. It deselects itself on UIControlEventTouchUpOutside. I also want it to deselect itself when there is a touch down outside of the button. Is there a good way to do this without subclassing UIWindow and overriding -hitTest:withEvent:? EDIT: I just found this question...

I'm having a problem with decimalNumberBySubtracting and decimalNumberByDividingBy.

Simply put, decimalNumberBySubtracting and decimalNumberByDividingBy are not working ... at all. No errors, just messed up results. I really need to fix this but Im not getting any errors and I cant think of any other way for how to do the calculation!! Im getting numbers like: 25784969139295000000000000000000000000000000000000000...

pickerview app crashing due to NSRangeException NSCFArray objectAtIndex: index (5)...beyond bounds (5)

Once again working through beginning iphone development and I am putting together a bunch of UIPicker type apps, the last one of which is a slot machine type of game, super simple. Anyway I am not really understanding why this error is coming up. to my understanding the picker view is asking its delegate for an object in the array that ...

'Tried to pop to a view controller that doesn't exist.'

I am getting this error when I call my method dismissView. Here is the method stub: -(IBAction)dismissView { RootViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil]; [self.navigationController popToViewController:rootController animated:YES]; } That should work, and I'...

Incompatible type for argument 1 of 'setBounds'

I am trying to do my own custom classes and learn C and Objective C. I'm recieving the error that there is an incompatible type for argument 1. I've defined a struct and class like this: typedef enum { kRedColor, kGreenColor, kBlueColor } ShapeColor; typedef struct { int x, y, width, height; } ShapeRect; @interface Shape : NSObj...

Checking singleton property with nil value causes error

When I check a singleton property that is nil, it kills my app. But when I check for nil on a class instance property, everything works fine. This works fine: self.MyProperty == nil but this will kill the app with “EXC_BAD_ACCESS” [MySingleton sharedManager].SomeProperty != nil What is the difference with the singleton that I can...

Why is my UIPickerView not animating like it should be?

Hello again! so this is basically like a slot machine type thing, very basic, but the problem Im having is that when you click the spin button the movement of the components is not animated, even though i have sent the animated argument a YES BOOL. I have no idea what I am doing wrong, any help would be appreciated. Nick ps download ...

NSDateFormatter and date conversion not working.

I am developing an app for the iPhone where I need to convert an date from an XML feed into just a HH:MM format. I have the following method that doesn't work and I have no clue what I am doing wrong. As an example, the timeToConvert string would be: "Mon, 01 Feb 2010 21:55:00 +0100" (without the quotes) The method works when the regi...

When evaluating an iPhone dev shop, best questions to ask?

We are currently in the process of evaluating a couple of iPhone development shops and we're putting together a list of questions/topics that we'll be asking them about when we meet. To make sure that we have the most relevant areas covered, what would you ask when evaluating an iPhone developer or development shop? Our main areas are:...

Global static const string variables in objective-c

(Newbie alert) I'm having trouble initializing a constant static string in objective-C: Basically what I want to do is create a constant string from a NSLocalizedStringWithDefaultValue(...) Any ideas? ...

Is there some functionality in Cocoa to display time intervals in natural language?

What I am searching for is a Cocoa (or third party) class that can display time intervals in natural language, e.g.: 10 seconds ago 1 hour ago 2 days ago Do you know anything that could help me to achieve this task without writing it by myself and melting in if-else hell? ...

Utility function for NSInvocation

NSInvocation seems to be one of the worst designed functions in Cocoa, so I decided to check if anyone had written a recipe to make using it easier. I found a recipe on Matt Gallagher's blog. Now to be able to do this he used some quite hackish techniques. Would you recommend using this code or is this technique too likely to lead to a...