8 votes

Check for iOS version

If you need to check if a certain method exists you can also check if the object supports it via respondsToSelector: like this: ...
iosdude's user avatar
  • 266
7 votes
Accepted

Unity3D native iOS plug-in to read pedometer data

Well, there is a lot to talk about here... I can't speak specifically about memory leaks here. I'm not sure how you're writing or compiling this code. But it's important to note that the iOS SDK ...
nhgrif's user avatar
  • 25.2k
7 votes

Generic singleton array with archiving and insertion functions

As my comment explains, there are some things about your code I definitely don't understand. This answer will focus on the parts that I know need to be changed. So, starting from the top... ...
nhgrif's user avatar
  • 25.2k
7 votes
Accepted

Custom Navigation Bar View Implementation

There are piles of formatting problems in this code which should be the first thing you strive to fix. You have inconsistent brace styles. Your IBAction methods ...
nhgrif's user avatar
  • 25.2k
7 votes
Accepted

NSUser defaults cellForRowAtIndexPath

#define UserDefault [NSUserDefaults standardUserDefaults] NO! There's a reason that Apple didn't bring #define pre-processor ...
nhgrif's user avatar
  • 25.2k
6 votes

Finding number of times each string in an Array of strings occurs in a large stream of characters (i.e large string)

Given that you stated this was for an interview, I'm going to focus not on how to make this code as fast as possible, but instead, the types of things I'd be looking for in an interview candidate. ...
nhgrif's user avatar
  • 25.2k
6 votes
Accepted

Ensuring non-expired token before every request

You could introduce a delegate instead passing another block in loadCategories method. First, the protocol: ...
eli's user avatar
  • 426
6 votes
Accepted

Bubble Sort in Objective-C

Returning a mutable copy of the temporary array makes no sense to me, perhaps you meant return [muArrRaw copy]; to return an immutable array (as the return type ...
Martin R's user avatar
  • 23.1k
5 votes

Basic ToDo App in Objective-C

There are a lot of things wrong here that I'm probably not mentioning at all. There is so much code that I instead want to focus on the big picture problems and the repeated problems (that you need ...
nhgrif's user avatar
  • 25.2k
5 votes

Up/down arrow key commands

Create an array that contains result values for upArrow, and another array for values of buttonTag for downArrow. Arrays are zero-indexed, so subtract 1 from your buttonTag value before using it as an ...
Duncan C's user avatar
  • 171
5 votes
Accepted

Point distance program written without a framework

It's an interesting idea to write Windows code in Objective-C. If you were using NeXTStep frameworks (or GNUStep) it would make a little more sense. I don't understand your desire to avoid frameworks, ...
user1118321's user avatar
  • 11.6k
4 votes
Accepted

Amanda's Relationship Tips app, with scroll performance issues

What is this? ...
nhgrif's user avatar
  • 25.2k
4 votes

Storing global constants in app delegate or singleton

Storing everything in a global singleton can be problematic, I wouldn't recommend that. I worked on a project once where all data ever passed to view controllers from outside was stored a giant ...
iosdude's user avatar
  • 266
4 votes
Accepted

Interview Coding Challeng for iOS Part 1 - the Static Objective-C Library

For having never done Objective-C before, this looks pretty good! Here are some things I would do differently. Library Name What is PCI7? For an acronym used in every class in your example, it would ...
user1118321's user avatar
  • 11.6k
3 votes

Given a set of random strings, write a function that returns a set that groups all the anagrams together in objective-c

Not quite right, though you're headed in the right direction since the complexity of a procedure can't be lower than the most complex part of it. If you have an operation that's O(n), and another one ...
jscs's user avatar
  • 302
3 votes
Accepted

Given a set of random strings, write a function that returns a set that groups all the anagrams together in objective-c

This would be a better way to do the final storage into the dictionary. Attempt to retrieve an existing list. If it does not exist, create it and add it to the dictionary. You can then unconditionally ...
jscs's user avatar
  • 302
3 votes

iOS SDK object to represent a place

You're trying to solve a solved problem. Just use CLPlacemark out of Core Location. It has already solved all the problems you've brought up in your question: how ...
nhgrif's user avatar
  • 25.2k
3 votes
Accepted

Have I created the <mutableDeepCopying> protocol properly?

Is it best to avoid the prefix NS, Yes. or would it be ok to change to <NSMutableDeepCopying> for consistency? No. You ...
jscs's user avatar
  • 302
3 votes

Simple plotting abstract base class and example subclass

There's a lot to comment on in the header alone... so I will... We can worry about the innards later. What's most important when writing a class like this is that the public-facing aspect make as ...
nhgrif's user avatar
  • 25.2k
3 votes

Downloading and parsing data

I have a few comments. Formatting: you have a lot of extra white space. I would recommend making line breaks mean something rather than putting them automatically between almost all lines of code. ...
sunny's user avatar
  • 1,825
3 votes
Accepted

UIButton Subclass - Overriding getters to return placeholder/default values

Is this an appropriate use of private variables? Is there any way to accomplish the behavior I want with a single variable rather a second optional settable variable for each color? This can be much ...
Martin R's user avatar
  • 23.1k
3 votes

UIButton Subclass - Overriding getters to return placeholder/default values

This is a small point and not really relevant since you should absolutely go with Martin's suggestion. But if you stuck with your old way of doing the properties, you should rewrite your getters to ...
overactor's user avatar
  • 654
3 votes

Convert NSInteger into NSString

Umm… this is a complicated solution that makes no sense. Why not keep it simple? ...
200_success's user avatar
3 votes
Accepted

Translating Objective-C use of static and +(void)initialize to Swift

Some thoughts: Make formatter a static stored property (which are guaranteed to be lazily initialized only once). This allows to get rid of the backing property <...
Martin R's user avatar
  • 23.1k
3 votes

Translating Objective-C use of static and +(void)initialize to Swift

A few observations: I might suggest that we want to use stored properties, like the original Objective-C code. I would be wary of using computed properties that return collections, as that can ...
Rob's user avatar
  • 2,397
2 votes

Creating a class which has a method running every frame

In this case, I would recommend using the built in SpriteKit methods for the best readability and the best control of the state while the game is running. Why do ...
bazola's user avatar
  • 8,579
2 votes
Accepted

Method for finding all classes

First and foremost, I must absolutely recommend against doing anything of this sort. If you want to know what classes are available in the scope, you need only look up at the imports you're making. ...
nhgrif's user avatar
  • 25.2k
2 votes

iOS Utility methods for UIView

I have three stylistic suggestions. Regarding your method names: ...SubviewSatisfyingCondition: sounds more Cocoa to my ears than your wording; especially the ...
jscs's user avatar
  • 302
2 votes

Basic ToDo App in Objective-C

I have a few suggestions: Do you need this outside the scope of class? ...
Ankit Thakur's user avatar
2 votes

Updating images in a weather app

You can put the resources in a dictionary, and loop it. ...
dengApro's user avatar
  • 381

Only top scored, non community-wiki answers of a minimum length are eligible