A late-binding, message-based, object-oriented language that is a strict superset of C and is primarily used for programming primarily on Apple's Mac OS X and iOS platforms. Objective-C can also be used on other platforms that support gcc or clang.
2
votes
0answers
25 views
applicationDidBecomeActive: Am I causing a memory leak?
in an ios app I´m calling this function everytime the app gets opened in the applicationDidBecomeActive: function. I´m using ARC. My concern is it could create a memory leak because it´s creating new ...
1
vote
0answers
29 views
Sample design Oauth2.0 flow
I have the following code that I hope developers will use.
[LKOauth showLogin: self data: data
success: ^(NSString * code) {
NSLog(@"%@", code);
}
...
1
vote
1answer
51 views
A better way to handle web services in an iOS app?
I'm building an iOS app that uses web services extensively. I've built classes that handle the requests. However since there are a lot of web service request - I need to find out how to detect which ...
1
vote
1answer
105 views
I subclassed AFNetworking to handle POST / GET requested - doing it wrong?
So I am pretty new to iOS development - I'm writing an app the uses web services, pretty extensively. With that in mind, I decided to use AFNetworking 2.0 and subclass AFHTTPSessionManager.
I ...
1
vote
0answers
27 views
I need code review on using singleton to access local database
As I get to some performance issues in my app and find that I use database access in a bad way.
So I decided to move to singleton pattern.
I need someone to review this code and confirm me that I made ...
4
votes
2answers
300 views
Will this code get me hired or laughed at? iOS MasterViewController
I plan on showing this project (only MasterViewController posted) during my interviews for an iOS developer position.
Question: Will this code get me hired or laughed at?
More Specifically:
How ...
0
votes
1answer
91 views
First iOS App ViewController Refactoring Guidance
I'm relatively new to objective-c/iOS. This is my first meaningful app.
My question is: How can I most effectively refactor the code in these 2 ViewControllers. I'm familiar with subclassing in ...
2
votes
1answer
104 views
Reviewing C function which captures the screen
I have created a function in C on OSX in Xcode which captures the screen, adds the mouse pointer to the image, rescales the image to fit a certain width X height requirement, and puts the rescaled ...
1
vote
0answers
77 views
Asynchronous networking IOS API calls
+ (void) makeRequestToEndPoint:(NSString *) endpoint values:(NSMutableDictionary *) params onCompletion:(SDKCompletionBlock) responseHandler
{
NSString * urlString = [self ...
2
votes
0answers
33 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 context did initialize before I return, so I added an infinite while loop at the end of the ...
0
votes
0answers
97 views
Created a BST for Objective-C, Looking for some feedback
I put together a Custom Linked List class in hopes to be used for a Talent/Skill Tree for a game, that allows for inserting nodes with NSMutableDictionary for Skills and Requirements along with a ...
1
vote
1answer
68 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:
__block ...
2
votes
1answer
46 views
Property getter implementation
I always see something like this:
- (NSMutableArray*)items {
if (_items == nil)
_items = [NSMutableArray array];
return _items;
}
Recently I wrote:
- (NSMutableArray*)items {
...
2
votes
3answers
158 views
Is there a better way of making an NSString with many argument values?
I have a form that I'm turning into a string value for an email, but the string value that I turn it into seems very complicated, plus I believe this way takes up a lot of memory and is somewhat slow ...
2
votes
2answers
145 views
Is this a correct way to write a convenience constructor?
I was reading more about the instancetype on Stack Overflow and now my question is:
For every convenience constructor that I write, do I need to have the corresponding one using init?
For example:
...
2
votes
1answer
142 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
126 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. ...
0
votes
0answers
178 views
SDWebImage - Fetch more images
What I am looking to do is, apart from setImageWithURL method of SDWebImage, load other images from the array of URL's.
So, in the completion block of setImageWithURL, I call a method ...
1
vote
0answers
41 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. ...
3
votes
1answer
24 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 ...
1
vote
1answer
281 views
How can I improve below Objective-C code to tint an image?
I have an image which is a black ring:
In my view, I need to display it as a white ring. So, to tint the image, I have written the below method:
- (UIImage *)getRingImage
{
UIImage *ringImage ...
2
votes
1answer
98 views
using C scope syntax for code organization purposes
Would you ever use curly braces for making your code more organized and readable? for instance I could have:
- (void)methodName {
...
// action 1
{
...
}
...
}
Where ...
0
votes
0answers
71 views
Class Designin patterns: how to design reusable classes
I want your opinion if this is decent design and how I can improve it if need be. I got the two classes DigBackground and DigParallaxBackgroundLayer (A parallax background is a image consisting of ...
4
votes
1answer
92 views
Simple yet efficient integer-to-object dictionaries?
Sometimes I need an NSDictionary-like object that maps a few integers (non-negative) to objects. At first glance, NSMutableArray is great for this, provided that the indexes aren't too high so I came ...
2
votes
1answer
53 views
A structure and helper functions for working with polar coordinates
Cross posting from Stack Overflow (not sure how to more correctly cross-post).
This started simple, as most things do...
I just wanted a little structure to hold polar coordinates for a totally minor ...
2
votes
2answers
223 views
iOS/Objective-C “if” best practice
I've got this code that I found in a project and I'm wondering how can it be done better:
- (void) setAlpha:(float)alpha {
if (self.superview.tag == noDisableVerticalScrollTag) {
if ...
3
votes
1answer
209 views
Logic question in a card matching game controller
I have a card matching game with a model of:
-Card
-Deck
-PlayingCard
-PlayingCardDeck
And another model that called CardMatchingGame.
Now, I had a task to add a button to the view for new game, ...
4
votes
1answer
108 views
Is there anything I can improve in this view controller implementation?
I'm using both Core Data and NSFetchedResultsController. Is there anything I can improve on? Thanks.
//
// RoutineTableViewController.m
// App
//
// Created by Me on 3/21/11.
// Copyright 2011 ...
0
votes
1answer
39 views
Creating a Playlist program (exercise)
Exercise:
Define three new classes, called Song, Playlist, and MusicCollection. A Song
object will contain information about a particular song, such as its title,
artist, album, and playing time. A ...
2
votes
1answer
143 views
Creating shapes program with multiple classes (different files) in Objective-C
I just started to learn Objective C with Programming in Objective C" of Stephen G. Kochanand and I would love to get your feedback to see if i'm getting OOP concept with Objective-C right, This is my ...
1
vote
1answer
47 views
First program in Objective c defining a 'Watch' class
This is the first program (that is not doing much basically), and I know usually you define classes in separate files, but just wanted to see if I got the syntax right, and the concept of using ...
-3
votes
1answer
156 views
iOS multiplayer pong game [closed]
I was trying to make a multiplayer Pong iOS app and ended up with this. It is almost good, except for one big bug. The 2nd player's paddle is moving the same way with yours. Basically, you're ...
1
vote
1answer
76 views
Is there a more optimal way to write the following encoding and then assign the result to a label?
Is there a more optimal (or concise) way to write the following:
I have to do some encoding and then assign the result to a label.
// encoding fix
NSString *correctStringTitle = [NSString ...
2
votes
1answer
54 views
A better approach to coding the a string value test for a NSDictionary object
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 the value prefix a UILabel with $, £, ...
1
vote
2answers
316 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 NSLog(@"Debug3"). And 2 sec on iPhone.
Method idea:
...
3
votes
1answer
143 views
Code review of forward invocation
Here's the situation. I'm writing a simple game and I had two main actors: GameController and GridView.
GridView is a UIView subclass displaying a grid with which the user interacts. It defines its ...
0
votes
2answers
837 views
iOS View Controllers - Default Lazy Loaded Properties (Tab Bar Item & Navigation Item)
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 ...
2
votes
2answers
150 views
Need an Obj-c code review for core data implementation
I'm just beginning my foray into iOS development and need a code review. I have a custom NSManagedObject that needs some smart setters. New to obj-c, iOS, and core-data development, I don't trust ...
2
votes
1answer
161 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
193 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 for all successful status codes. Here ...
2
votes
1answer
123 views
Rot47 an NSString Category
As a JAVA native, i am always a litle worried when doing objective-c... memory leaks and pointers flying at my head...
All comments are welcome on the Category below, the Category functions are ...
2
votes
2answers
213 views
Objective-C Singleton Implementation
is this the right way to do a singleton in Objective-C ? (coming from Android background, with a little understanding of threading)
#import "ItemsManager.h"
#define kNumMaxSelectableItems 15
...
3
votes
1answer
178 views
Spliting string to array by number
I have two functions to split string to array of strings.
Input string is: (1Letter E|V|R) + 8 number, last component of string (1Letter + V) + 8 or less numbers.
I'v got two functions advised to ...
3
votes
2answers
152 views
Storing and iterating over multiple NSError pointers
How would you refactor this kind of code? I've unsuccessfully tried several approaches (NSArray, NSPointerArray, plain C array), but always ran into pointer type checking error.
NSError *error1;
...
4
votes
2answers
2k views
Dependency Inversion / Injection? - Networking code in model classes
@implementation User
- (void)refreshProperties
{
assert(!self.isSyncing);
NetworkOperation *op = [[NetworkOperation alloc] initWithEndPoint:GetUserDetails parameters:nil];
[self ...
1
vote
1answer
235 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.
...
0
votes
1answer
102 views
Optimize nested enumerate blocks?
Well,
i have 3 nested NSEnumeration loops, used to get the textfields of a custom cell, in a custom table in a custom view in a controller...
How can i change this code to make more readable and more ...
5
votes
2answers
149 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 on a single if, including the ...
2
votes
2answers
108 views
Is there a better way of showing multiple NSDictionaries?
I have a method that contains a bunch of NSDictionaries (in fact, the only reason I have that method is to create those NSDictionaries). While I don't believe there are enough NSDictionaries ...
1
vote
1answer
99 views
Iterating over object properties
I'm working with lots of code that looks like this:
-(void)switchToPercent{
int tmp;
tmp = (statisticsObject.idag3_orig != 0) ? statisticsObject.idag3_orig : [self ...