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

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.3k
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.3k
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.3k
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.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.3k
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.3k
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.7k
4 votes
Accepted

Amanda's Relationship Tips app, with scroll performance issues

What is this? ...
nhgrif's user avatar
  • 25.3k
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.7k
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
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.2k
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

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.3k
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.2k
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,482
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

First Tic Tac Toe game

Some additional points: In -(void)makeMoves, the initial values of int x; int y; are undefined, and testing their values in ...
Martin R's user avatar
  • 23.2k
2 votes

Sorting an array of time-specific tasks of varying importance

I see many things that can be cleaned up here just to make the code clear and readable; I'm not sure I can be comprehensive with those, and because of that I'm going to mostly ignore the logic. I've ...
jscs's user avatar
  • 302
2 votes

iOS SDK object to represent a place

I think the concerns here about accurately modelling international addresses are well founded but the root question seems to be a simpler problem. Given an object with some properties which may not ...
Jonah's user avatar
  • 516
2 votes

Current user as a class-level property in Objective-C and Swift

(I am referring to the Swift code only.) You can declare a property as public private(set) var name: String? to make it public read-only, but internally read-...
Martin R's user avatar
  • 23.2k
2 votes
Accepted

Sorting Timestamped Messages (iOS)

If both new and old messages are sorted it's basically a merge of two sorted arrays, similar to the merge step in merge sort. It can be done O(n + m) time. I'd suggest you to look into how that's ...
iosdude's user avatar
  • 266
2 votes

Updating images in a weather app

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

Controlling Drone with iOS Speech Recognition

Generally All library of Speech recognize will take few seconds (around 1 to 5 seconds) to respond on any recognition so its normal time for your response. But what i suggest here is default API of ...
CodeChanger's user avatar
2 votes

Create a stack implementation that handles the multi thread scenario

This is very easy to read and well written. As far as I can tell, it accomplishes your goal in a very straightforward way, and should be very easy to maintain going forward. Does It Do Enough? Overall,...
user1118321's user avatar
  • 11.7k
2 votes
Accepted

Interview coding challenge for iOS Part 2 - the application in Objective-C and Swift

(The question is more than two years old, and both Xcode and Swift have been developed substantially in that time. The following review is written with the current Xcode 10.3 and Swift 5 in mind.) ...
Martin R's user avatar
  • 23.2k

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