Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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
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
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.3k
6 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
  • 181
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

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.3k
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

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

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

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

Sychronous wrapper around UIApplication.openURL:options:completion:

That code should work, but blocking the main thread is never a good idea. That's why the method was changed in the first place. I suggest a deeper refactor of your code so that you use the new async ...
Duncan C's user avatar
  • 181
2 votes
Accepted

SIMD Mandelbrot calculation

A couple of thoughts: You say Given that I'm calculating 8 times as many pixels at once, I was hoping for more. Yes, simd delivers some pretty spectacular performance improvements when doing ...
Rob's user avatar
  • 2,552
2 votes

SIMD Mandelbrot calculation

I tried using the fused multiply-add and multiply-add-negate instructions, and they made the code significantly slower than using 2 or 3 separate instructions, unfortunately. This is usually ...
user555045's user avatar
  • 9,844
1 vote
Accepted

CommandLine StreamFormatTester

The "file and format ID" can be created in one step as ...
Martin R's user avatar
  • 23.3k
1 vote

Checking that a 6-digit number is not repeated and not in sequence

I would write a separate function for validating a string (so that it has a name and you can talk about it). Then, I would not use regular expressions for it but just simple code: The length must be ...
Roland Illig's user avatar
  • 21.3k
1 vote

Initializing a big static array for a card-based iOS app

Put all this static data into a .plist file. Now you can cleanly maintain that seperate from your source code, and easily suck the whole thing in as needed. ...
trapper's user avatar
  • 231
1 vote

Initializing a big static array for a card-based iOS app

Well if you are looking to reduce the number of properties your objects have, you'll have to figure out a way to refactor the class interface. But seeing as you have a flash card app, I don't think ...
A O's user avatar
  • 111

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