objective-c

Hacking the NSDocument architecture

I'm working on creating an NSDocument-based app with tabs for documents. I have found that it wasn't really designed for this. Apple designed the architechture to allow multiple windows for a single document but not the other way around. I have it basically working but I have started to run into weird issues. For example, when a window i...

Can this loop be optimized?

I'm at the debugging/optimization phase with an iPhone app. I have one bottleneck left - the only place where the program has a noticeable lag, and it's in the following loop: (By the way, I've renamed the vars with letters and types. (The real names are much more human-readable in the actual app, but make little sense out of context, so...

Animating an NSView in from Below.

How would I animate an NSView in from below. I know there are tutorials like Marcus Zarras which shows how to change from one view to another, but how would I animate in a view which isn't going to replace another view. ...

Objective C: Size of an array changes when passing to another method

Hi, I've got a small problem. I've got an array and its size changes when passing to a c-function from an objective-c function. void test(game_touch *tempTouches) { printf("sizeof(array): %d", sizeof(tempTouches) ); } -(void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event { game_touch tempTouches[ [touches count] ]; ...

Is garbage collection used in production quality Cocoa apps?

I'm mainly wondering about the affect that garbage collection would have on performance. Is the use of garbage collection frowned upon for release apps? Another concern that I can think of is that using garbage collection could lead to sloppier programming. Do you use garbage collection in your apps? ...

Generating alert to User when didReceiveMemoryWarning is called

I've seen some apps that generate a warning when low memory is detected. I tried to do this in my app but ran into a problem. Using the simulator to simulate a memory warning, the alert generated pops up twice before I can hit "ok" and pops up 9 more times after that times before it finally goes away. Is it a bad idea to generate an ...

Simple way to parse XML to an tableview Objective C

For an iPhone application I need to request data from an online database. I choice to use for an restful web service. Main reason because it will connect to an JAVA server. I did find a useful wrapper that helps me to get the data but now I need a good workaround to play with the data. The output is XML. If it is better to use JSON or s...

why are my methods overwriting self values and passes arguments even after I copy them into new instances?

So im working on programming in objective c 2.0 book, and I'm working on a method to subtract 1 fraction object from another, I have the algorithm and everything set and it does work, but in going through the process (debugging) i found that even though i was copying the fractions into new instances so I wouldnt mess with the values in t...

Generate a random number with a random numberlength in Objective-C

Hello, always when I try to generate a random number with Int = arc4random % MAXNUM the length of the number is as long as the MAXNUM number length -1. So if I set arc4random % 1000000 the number is between 100000-999999. How can I get different numbers like 78, 476 or 4842? Here a sample: int number = arc4random() % 1000000; outputLa...

Change UITextField background when editing begins

I'd like to change the background image of a UITextField when it becomes the firstResponder to show the user that it has focus, similar to the :active or :focus pseudo-classes in CSS. I'm guessing that I may need to do this programmatically; so any help is greatly appreciated. -Giles ...

Swip from one view to the next view

Hello, I have an app with two views and ViewControllers. How can I let the user swip from one view to the next view like in the homescreen or the weatherapp. I know that there is a page control in the Interface Builder, but it is just an Indicator on what page the user is. Thanks and sorry for my bad english! ...

How to add two numbers like 7 and 6 = 76 or 3 and 3 = 33

Hello, sorry for my bad title (and noob question), but how can I add two numbers like 7 and 6 and the result should be 76. Is there a operation symbol in objective-c? Thanks and sorry for my bad English. ...

Measuring velocity via iPhone SDK

I need to implement a native iPhone app to measure the velocity of the phone (basically a speedometer). I know that you can do so via the CoreLocation API fairly easily, but I am concerned about battery consumption since this is to be a real-time measurement that could be used for up to a couple of hours at a time. My understanding is ...

How can I get my program to do anything when a "multidigit number with all digits identical" appears?

Hello, my program generates random numbers with up to 6 digits with int number = arc4random % 1000000; I want that my program do something when a number like 66 or 4444 or 77777 appears (multidigit number with all digits identical). I could manual write: switch (number) { case 11: blabla...; case 22: blabla...; (...)...

Monitoring UINavigation stack

Is there a way to monitor what view controller the navigation controller had before it pushed on the current view controller. also the opposite, what view controller it popped off the stack before getting to the current view controller? Thank you in advance ...

Basic route information with Cloudmade

Hi, I am trying to use CloudMade's route-me service in my application. All I need from the service is driving distance between two locations, I don't want to display it in a map. There doesn't seem to be any tutorial in CloudMade's website that handles this. I mailed to the support address they have provided. Nothing back from them so ...

"Nested functions are disabled, use -fnested-functions to re-enable"

Hello, I want to use this code (from my last question (thanks Adam)), bool AllDigitsIdentical(int number) { int lastDigit = number % 10; number /= 10; while(number > 0) { int digit = number % 10; if(digit != lastDigit) return false; number /= 10; } return true; } but the c...

Sorting NSStrings of Numbers

So I have an NSDictionary where the keys are years as NSString's and the value for each key is also an NSString which is sort of a description for the year. So for example, one key is "943 B.C.", another "1886". The problem I am encountering is that I want to sort them, naturally, in ascending order. The thing is that the data source of...

How to get a blinking button? (two alternating pictures)

Hello, I want a blinking button. Actually my button look like this: [redButton setImage:[UIImage imageNamed:@"Button1.png"] forState: UIControlStateNormal]; [redButton setImage:[UIImage imageNamed:@"ButtonPressed.png"] forState: UIControlStateHighlighted]; Now I want to change the Buttonpicture in the normal State every second from Bu...

Making a window pop in and out of the edge of the screen

I'm trying to re-write an application I have for Windows in Objective-C for my Mac, and I want to be able to do something like Mac's hot corners. If I move my mouse to the left side of the screen it will make a window visible, if I move it outside of the window location the window will hide again. (window would be pushed up to the left s...