A late-binding, message-based, object-oriented language that is a strict superset of C and is primarily used for programming on Apple's Mac OS X and iOS platforms. Objective-C can also be used on other platforms that support gcc or clang.
15
votes
14answers
4k views
Bad Practice to have Long If-Else statements?
EDIT: One of the bigger questions I have is that, is using switch-case more efficient then using this?
Right now in my application (a weather app), I have one section of code in my View Controllers ...
10
votes
1answer
158 views
10
votes
3answers
1k views
Am I sending a message to an object in the main thread the good way?
I have written this (truncated) code to fetch some tweets:
...
8
votes
1answer
66 views
First simple program; counting button presses
This is my first solo Objective-C program... it does the complicated task of displaying a button and counting how many times it's been pressed. It retains that count (along with the last time it was ...
8
votes
1answer
205 views
NSInvocation Implementation
I'm using NSInvocation as a choke point in my app to help manage threading and reduce the amount of redundant code. The purpose of this class is to pass arguments ...
7
votes
2answers
2k views
Game with tile map - Sprite-Kit
I'm a novice programmer learning Objective-C in my spare time. I would greatly appreciate any help or advice with my code. I want to follow best practices whenever possible. I know that I am ...
7
votes
2answers
1k views
Custom numberpad on an iPad
I'm an active user on SO, however I just found this site and this is my first question here. I am a self-taught programmer who has been programming for a long time, but mainly just for personal ...
7
votes
2answers
171 views
Creating a better NSLog
So, generally when I write iOS code, I will start with a lot of calls to NSLog, which is a macro that with print the string you send it to the console.
There's a ...
7
votes
1answer
120 views
iOS7 ChessGame UIChessboardView Design
I've been designing UIChessboardView in the likeness of UITableView using protocols and delegates.
UIChessboardView.h
...
7
votes
1answer
2k views
What can I improve on my iOS PDF class?
This is the first PDF class I have made for the iOS using code from Apple's samples. There could easily be stuff here wrong that I am missing.
I intend this to get images out of for a layer, for ...
7
votes
1answer
79 views
7
votes
1answer
2k views
Review of Tic Tac Toe game in Objective-C
I am completely new to Objective-C. I have written a simple SingleView Tic Tac Toe Application application for learning purposes. While writing the app, I've tried to be as much sound as I could. ...
6
votes
2answers
183 views
iOS App - Interface for user log in using a call to a web service API
I have a navigation controller set up with a user code and password and a log in button. When the user clicks on the Log In button or the return key on the keyboard on the password text box - the ...
6
votes
3answers
140 views
HTTP scraper not clean and straightforwardly coded?
A job application of mine has been declined because the test project I submitted was not coded in a clean and straightforward way.
Fine, but that's all the feedback I got. Since I like to ...
6
votes
2answers
100 views
User Interface for Strategy Game
I've been working a strategy game for iOS for a little while, and each time I add functionality to the game model I'm finding myself building a lot of UI code to sync up with it. I believe that my ...
6
votes
2answers
203 views
How best to keep track of an unknown number of objects?
I have a manager class that will manage an unknown number of objects. I'm currently storing the objects in a NSMutableArray object, and when I need to find one, I ...
6
votes
2answers
162 views
Optimize IF condition block
this is my first post here!
How can i optimize the if condition on this snippet?
The only one difference is && [self isCurrentPosition:i].
How can made it ...
6
votes
1answer
52 views
Save Games on iOS with NSCoding
This is the second time I have implemented saving and loading for a game using Objective-C. I am using the built in NSCoding methods. I would love to hear opinions about NSCoding and whether or not ...
6
votes
1answer
576 views
Canonical Implementation of a Subclass of NSOperation
I would like to develop a kind of template or canonical implementation for a concurrent subclass of NSOperation.
Requirements:
Thread safe API.
...
6
votes
1answer
485 views
Optimizing a search for list of artists in iTunes library
I'm trying to get a list of all artists on an iPhone / iPod touch music library. The best way I've found has been to group by artists (the convenience constructor on MPMediaQuery) and to iterate over ...
5
votes
2answers
217 views
Is this a decent first Objective-C project, and can others learn from it?
This isn't my first time coding in Objective-C, but I do sometimes fantasize about there being a de facto standard "practice" project.
I'm toying around with this code, and I'd like your input. ...
5
votes
2answers
3k views
5
votes
3answers
505 views
Custom iOS chat interface design & functionality
Preamble
So, as most of you have likely also noticed, chat components, at least at a basic level, are becoming very common with lots of apps. I found myself tweaking and redesigning the interface ...
5
votes
1answer
95 views
Console monster battle game
This code currently works, but I'm new to Objective-C from a Python/PHP background. How can I improve it/make it more Objective-Cesque?
Header File/Interface
...
5
votes
1answer
96 views
How can I condense several IBAction methods in a class with a delegate?
I have the following class:
MyProtocolClass.h
...
5
votes
1answer
120 views
5
votes
1answer
191 views
UIView subclass – done right?
Generally, UI code is painful and full of kludges. (At least, mine was like that.) Recently I have decided to put an end to it and try to learn how to write good and reusable UI code.
So here is the ...
5
votes
1answer
249 views
Is there a memory leak in here?
I'm newish to obj-c and I have some code that works, but I'm thinking I may be leaking memory as I have two retain statements and no ...
5
votes
1answer
64 views
App for listing places close by - building up models
I'm fairly new to Objective-C. The app I'm trying to make, is using the foursquare API to list up places that is close by. I've re-written this app more times than I care to admit, because I feel the ...
5
votes
1answer
326 views
How to make this function thread-safe?
I have an array that I want to enumerate using blocks concurrently. However, I'm having trouble making this thread safe. I am new to using blocks and locks, so I am hoping someone may be able to push ...
5
votes
1answer
423 views
Handling rotations in iOS painting app
I have an iOS app that support all orientations. I sometime notices performance issues when I rotate the device, and sometimes it crashes, badly. And it's not as smooth as other apps. This is my first ...
5
votes
2answers
87 views
Adding features to a strategy game
I'm working on a basic strategy game for iOS and I have a question about the overall layout of the code in the program. I added some features to the game today and I had to add code to several ...
5
votes
1answer
113 views
Managing People in a SimCity Clone
So I am working through a few different game ideas as I learn programming, and I could definitely use some feedback on my latest project. This is a simple SimCity clone. So far I have created a City ...
5
votes
2answers
1k views
Splitting an NSArray into an NSDictionary of array more elegantly
I need to split one NSArray into NSDictionary. Every key in NSDictionary will contain an ...
5
votes
1answer
384 views
Logic in a card matching game controller
I have a card matching game with a model of:
Card
Deck
PlayingCard
...
5
votes
2answers
102 views
Optimize a synchronization with remote web service
I am writing a method to synchronize the local Core Data entities with a remote web service (in this case Parse.com).
To update changed or created objects, I fetch all where the "updatedAt" date ...
5
votes
1answer
249 views
Presenting modal dialogs from XIB in Cocoa: best/shortest pattern?
Below is my typical WindowController module for presenting a modal dialog (could be settings, asking username/password, etc) loaded from a XIB. It seems a bit too complex for something like this. Any ...
5
votes
2answers
216 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 ...
5
votes
0answers
28 views
Unhandled Exception handler that captures a screenshot
So, whether you're still in the development stages or your app is already on the app store, you always hope your app isn't crashing. But if it is, you want to be sure you've got good crash reports, ...
4
votes
3answers
120 views
Import management
I am working on a personal iPhone ObjC project, and was recently getting frustrated with how tedious importing the same set of headers over and over was getting… So I created a header file that ...
4
votes
2answers
147 views
Worker AI and Job Queue Management for Simulation Game
So I've been working on AI for a Tower Building simulation game for quite a few days, and I think the code would really benefit from review. I'm a hobbyist programmer, but I really care about doing ...
4
votes
2answers
106 views
Skill Upgrades for Strategy Game
I built a simple class to handle skill increases for the workers in a strategy game for iOS. The basic idea is that whenever a worker finishes a job, their skill (which starts at 0) will increase by ...
4
votes
3answers
76 views
Job Queue for Strategy Game
I posted about this basic problem a while ago, and I got the recommendation to move the code for managing the Jobs of my game to another class. I have been working on it for a little while now, and I ...
4
votes
1answer
1k views
UITableView cellForRowAtIndexPath
I'd like to see how I can improve this code, as I know it's bad practice to have cell reuse identifiers like this, but I could not find any other way to keep the cells that contain images from calling ...
4
votes
1answer
204 views
iOS / Objective-C Basics
Coming from Java & Android development and Objective-C still is a bit strange to me, but I just went in head first and started writing code. Before I started getting really far into it, I just ...
4
votes
1answer
151 views
NSTask with Git
This is my first real Cocoa app that I am writing. The first version of this app was just one long applescript. So in my app auto git, I have an NSTask instead of Tell terminal. My code looks like ...
4
votes
3answers
581 views
4
votes
1answer
112 views
Obfuscating iPhone Password
If I need to obfuscate an iPhone password that is hardcode (Oauth Client Identifier and Client Secret), would this be a way to do it?
...
4
votes
1answer
164 views
applicationDidBecomeActive: Am I causing a memory leak?
Using ARC, I'm calling the following function in an iOS app every time the app gets opened in the applicationDidBecomeActive function.
My concern is that it could ...
4
votes
2answers
740 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 ...