Questions tagged [ios]

iOS is an operating system for mobile devices developed by Apple Inc. that is currently used in their iPhone, iPod touch, iPad, and Apple TV (2nd generation) devices. It shares a lot with Mac OS X, but is optimized for touch-based interfaces. Use this tag for questions about iOS-specific code.

Filter by
Sorted by
Tagged with
4
votes
2answers
1k views

MasterViewController

I plan on including this work in a portfolio. Will this code get me hired or laughed at? More specifically: How would you rate the general complexity of the code? How bad does the code smell? Is ...
5
votes
1answer
322 views

iOS App ViewController

How can I most effectively refactor the code in these 2 ViewControllers? I'm familiar with subclassing in Objective-C and have used it extensively else where with <...
4
votes
2answers
7k views

Asynchronous networking iOS API calls

I have the code above in my iOS SDK that I am building that makes it easy for users of the SDK to make API calls. Basically, users can specify an API endpoint and easily make API calls. Is there any ...
4
votes
1answer
116 views

Is there a better way to make sure a variable is initialized when using blocks?

I have a method to provide an NSManagedObjectContext using UIManagedDocument. I need to ensure that the ...
1
vote
1answer
202 views

AutoreleasePool NSString Automatic Reference Counting

I have some doubt about how NSString is released in ARC Mode. I would like to know if have something i can do to release a nsstring when i want in arc mode. Take a look at this code: ...
2
votes
1answer
2k views

Refactoring to avoid if-else in numberOfRowsInSection and cellForRowAtIndexPath

Below is the code that I would like to refactor in order to avoid if-else statements in cellForRowAtIndexPath and ...
4
votes
1answer
182 views

URL percent encoding function

I wrote a custom URL encoding function and I'd like to run it past a few other experienced C developers. I have tested it on a few strings, and it has worked on all of them. This is to be run on ...
2
votes
1answer
385 views

Drawing to a canvas based on user input

The following is a code written in Javascript. It let's me change the appearance of a canvas depending on user input. The question is, how can I make this code more CPU efficient? I ask that because ...
2
votes
1answer
3k views

Pulling Objects & Values From Arbitrarily Nested JSON

I got tired of stringing together objectAtIndex: and objectForKey: and hoping nothing fails along the way. I parse a lot of JSON from sources like the Google Directions API and it was cluttering my ...
0
votes
3answers
1k views

Objective-C class for placing UI elements based on screen size

I'm always programmatically creating and laying out UI elements in multiple ViewControllers and I've wanted an easy way to get relevant Screen information (sizes/points) globally using a helper class. ...
3
votes
1answer
483 views

Select first or last object from id<NSFastEnumeration>

I found this code in our project and it just feels like the wrong way to do what it seems to be doing ...
1
vote
1answer
160 views

Is this proper code for removing a CCSprite under certain conditions?

This is a "answer" to my own question over at stackoverflow, head over there to see what I am trying to accomplish. https://stackoverflow.com/questions/16744109/deleting-the-proper-ccsprite-from-an-...
2
votes
1answer
45 views

Creating an expanding CCSprite cluster

I am creating an "explosion" of circle sprites from the character with this code, and I was wondering if there is a more effective way to do such things, because this just seems too stupid. (This is ...
2
votes
1answer
3k views

Tinting an image

I have an image which is a black ring: black ring http://imageshack.us/a/img51/2029/blackcb.png In my view, I need to display it as a white ring. So, to tint the image, I have written the below ...
3
votes
1answer
514 views

Classes for background layer and parallax effect

I have two classes DigBackground and DigParallaxBackgroundLayer (a parallax background is a image consisting of several images ...
2
votes
1answer
313 views

A structure and helper functions for working with polar coordinates

This started simple, as most things do. I just wanted a little structure to hold polar coordinates for a totally minor class. But starting with this answer and borrowing from existing Objective-C ...
0
votes
2answers
546 views

iOS/Objective-C “if” best practice [closed]

I've got this code that I found in a project and I'm wondering how can it be done better: ...
6
votes
1answer
886 views

Logic in a card matching game controller

I have a card matching game with a model of: Card Deck PlayingCard ...
4
votes
1answer
678 views

NSFetchedResultsController implementation

I'm using both Core Data and NSFetchedResultsController. Is there anything I can improve on? ...
1
vote
1answer
119 views

Encoding and assigning the result to a label

I have to do some encoding and then assign the result to a label. Is there a more optimal (or concise) way to write this? ...
3
votes
1answer
365 views

Applying a currency symbol based on a tested string value

My conditional code here seems repetitive and long. Is there a better approach? I want to test for a string value in a NSDictionary object and then depending upon ...
1
vote
2answers
2k views

Optimizing iOS method in objective-c

I have such method and have a hard time optimizing it to run better. It takes roughly 1 sec with 100 units to get between NSLog(@"Debug2") and ...
1
vote
2answers
4k views

iOS View Controllers - Default Lazy Loaded Properties (Tab Bar Item & Navigation Item) [closed]

It is a little thing about UIViewController, but it has always bothered me - the boilerplate code needed to setup some of a view controller's default properties (e.g. the tab bar item and navigation ...
3
votes
2answers
1k views

NSManagedObject in need of smart setters

I'm just beginning my foray into iOS development and need a code review. I have a custom NSManagedObject that needs some smart setters. I'm new to Objective-C, ...
1
vote
1answer
417 views

Optimization of percent match code

I have the following method that will take the car parts I searched for and match them to my car object in array. Then it tells me the percent match. Example: Car.h has NSSet toCarParts. toCarParts ...
2
votes
1answer
403 views

Initialize a bunch of NSDateComponents objects at once (in a loop)?

I'm developing an iPhone app that is heavily Calendar-based, and it requires a good amount of (what I'm calling) "date boundaries." I use these "date boundaries" to fetch EKEvents from specific ...
2
votes
1answer
483 views

Testing the same code with different input data

I would like to get an advice regarding how to test the same code with different input data. I would like to test that method operationSucceeded will be invoked ...
5
votes
2answers
317 views

Rot47 an NSString Category

As a Java native, I am always a little worried when doing Objective-C because of memory leaks and pointers flying at my head... All comments are welcome on the ...
2
votes
2answers
278 views

NSArray and NSNumber-int conversions

I have a textView which is displaying a string. I also have an array which keeps track of where every line begins, it stores the "start index" or NSRange.location for every line. However, when text ...
6
votes
2answers
4k views

Dependency Inversion / Injection? - Networking code in model classes

...
1
vote
1answer
7k views

iOS UITableView; saving cell checkmarks to disk

As per suggestion on SO, I am posting my code here to be reviewed. It was said I should not be saving and reading from disk so many times when a user selects and deselects a cell in my tableView. <...
1
vote
1answer
1k views

Loading of images

I recently started game development, but one of the things that I never put much thought to was the loading of images. I'm curious as to advice for improving my current code on loading images. I'm ...
10
votes
3answers
3k views

Custom numberpad on an iPad

I am a self-taught programmer who has been programming for a long time, but mainly just for personal projects. I would like to improve my skills and am open to any suggestions that you may have, but ...
3
votes
1answer
287 views

Improving calculation code

I'm making a converter app, and after realising I would have to type about 200 lines of code to get it working with more than 5 units converted, I should have a better conversion calculation. What I ...
4
votes
2answers
3k views

Age verification in Objective-C

I'm creating some age-verification functionality for an iOS app. The user is presented with a UIDatePicker object, and the latest selectable date should be today ...
6
votes
2answers
603 views

Am I reconstructing the buffers correctly

I am writing a networked audio application that sends the audio in 320 byte chunks, later I need to provide the player a bigger amount of bytes to play so I try to merge 2 or more chunks into one ...
7
votes
1answer
165 views

Upgrading animation code

I understand that this animation code is outdated: ...
2
votes
1answer
289 views

Core Data code for manually creating a lot of entries from old ones

Does this looks ok to everyone? ...
3
votes
2answers
602 views

Data model code review for iOS app

I'm new to iOS development and I'm having trouble figuring out how to efficiently load my app's data at launch time. My app consists of a UITableView that is populated with a list of songs. Each cell ...
5
votes
1answer
1k views

Parsing NSDictionary from NSJSONSerialization

playerObject is an NSDictionary from JSONObjectWithData:options:error. I'm trying to update ...
1
vote
1answer
127 views

Efficiency of grid generated by for-in loop

I've spend the last several hours working on a loop designed to take items in an array and arrange them as a so to speak "gird" of ...
2
votes
1answer
438 views

Tips on good practice in my bash script that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox

I am running a scheduled script on my iPhone that logs in to a website, downloads a PDF, adds it to iBooks and uploads it to dropbox. All of this happens only when it has WiFi access. I want to make ...
19
votes
15answers
8k views

Updating images in a weather app

Right now in my weather app, I have one section of code in my View Controllers to set up the condition image and the background image. It has about 400 lines of if-<...
4
votes
2answers
5k views

Optimize sorting of Array according to Distance (CLLocation)

Currently my below code takes an average 9.27300 every time I run it. This is an iOS application and I can't expect the user to sit there for roughly 10 seconds. This code takes an array (...
2
votes
1answer
772 views

Core Data model of video and entities

I have a Core Data model with two entities: Video and Playlist. A Video can be a member of ...
2
votes
3answers
1k views

Standard delegate methods

I'm aware standard delegate method declaration should include the object that triggers the method, usually of the class that declared the protocol. That's fine when the delegate method includes ...
15
votes
3answers
799 views

Sample game code for applying to a development firm

I am contemplating working with a development firm, and had asked for this piece of sample code. Could you please take a look and let me know if this is a quality piece of work, or if it needs ...
2
votes
2answers
5k views

iOS4 alternatives for dismissViewControllerAnimated:completion:

My inspiration for creating this protocol came from iOS 5's "dismissViewControllerAnimated:completion:" addition to UIViewController. I wanted this functionality in iOS 4.3. I find using the modal ...
3
votes
1answer
2k views

Display complex mathematical equations in iOS 5.0 devices

I am working on an app for iPhone and iPod Touch that has to show complex mathematical equations like algebraic, integration, summation formulas along with some text. For that I have used Quartz2D ...
6
votes
3answers
832 views

App for allowing the user to type in chemistry formulas using a custom keyboard

Essentially, I am making an app that allows the user to type in chemistry formulas using a custom keyboard. The keyboard will have several keys, for example, "Na", "H", and "O". Pressing them in ...