Skip to main content
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
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
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

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

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

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
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

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

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

Updating images in a weather app

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

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
  • 241
2 votes

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
  • 121
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
  • 10.2k
1 vote
Accepted

A C++ wrapper for Apple CoreFoundation

This is a really great idea! I could certainly use a class like this. Here are some thoughts: Don't Multiply Declare public It's very odd that you're prefixing ...
user1118321's user avatar
  • 11.7k
1 vote

Objective C implementation of Swift's if-let

My suggestion would be: Don't do it. The main disadvantages (in my opinion) are: As you noticed, commas inside the macro argument are not handled, leading to "strange" error messages: ...
Martin R's user avatar
  • 23.3k
1 vote

Populate TableView with JSON data

Firstly ListViewController does not need to know where the List comes from. Use dependency injection here, so set up List and inject it into ListViewController before it gets presented. Now why not ...
trapper's user avatar
  • 241
1 vote

Checking for many alertable conditions before saving customer information

You can absolutely extract validation part out of this method because almost every validation is depending on self.service object. 1 Write a method in ...
D4ttatraya's user avatar
1 vote

Create a stack implementation that handles the multi thread scenario

Some possible improvements: There is no need to make the stackArray property atomic because access to it is already protected with ...
Martin R's user avatar
  • 23.3k
1 vote

Populating a UITableView with staff members using Firebase data

First of all you are getting single response with all staff detail in single dictionary so Why you are filtering in different array ? Suggestion : You can use filtering on single dictionary with ...
CodeChanger's user avatar

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