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 ...
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, ...
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 ...
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 <...
3
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 ...
3
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 vector/...
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.)
...
3
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.
...
3
votes
Modularizing a Game Scene in Sprite Kit
Disclaimer: I don't know Objective-C
However, if it's like other object-oriented languages, I think a good approach would be to encapsulate the Dwarf and Animal rendering into functions of DTDwarf and ...
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 ...
2
votes
1
vote
How to use string constants correctly
I'm going to be the heretic in the room... I think your first code sample is just fine and doesn't need any refactoring at all.
Let's pretend for a moment that the code lines in question are in wildly ...
1
vote
How to use string constants correctly
You ask:
Should I assign each string to a variable? Many strings are not shared and will only be used once.
Obviously, in the other case, where the string is reused/shared, then of course one would (...
1
vote
Objective C String to JSON formatting
In your question, you don't make it clear what needs to be dynamic and what can be static. If the only string you ever have to parse is the one you showed, then don't bother parsing it, just make the ...
1
vote
Convert C to Swift
Since this is a good chunk of my day job, I've got a bit of feedback for you 🙂
Just keep in mind that Swift is a very flexible language! Your translation works, so you can use as much or as little of ...
1
vote
Accepted
Convert C to Swift
A few suggestions:
Don't have everything be part of a class. In Swift, you can have free functions, just like in C. Remove the class AverageRSSI: NSObject { ... }.
...
1
vote
Accepted
iOS Attributes in the data model
In terms of number of properties, I wouldn’t worry about that. There are situations where you can have lots of properties. As the philosopher says, “it is what it is.”
Obviously, from a data modeling ...
1
vote
Accepted
3D vectors in Objective C
You asked:
when do I use entity.position vs [entity position]?
The former is syntactic sugar for the latter, used with ...
1
vote
Checking user verification status
It's good that you are getting that feeling that something isn't right. You are violating the single responsibility principle. Your view controller should only be responsible for it's view hierarchy, ...
1
vote
Creating directory within Application Support, and preventing iCloud backup
File System Basics tells us:
The contents of the Library directory (with the exception of the Caches subdirectory) are backed ...
1
vote
Accepted
Multiple AFNetworking calls In a view controller
From my point of view, there's nothing wrong with doing the network requests like you are doing it IF you are using MVC. You are just asking the model for the target request and using blocks to manage ...
1
vote
Multiple AFNetworking calls In a view controller
There is nothing wrong with multiple network requests, it will not have any impact on battery that you need to worry about.
Your code however needs a lot of work. None of these network requests ...
1
vote
Accepted
Objective-C and AFNetworking
Don't pass 'params' in via a public method. What are these params? Make the method signature explicit.
So instead of
...
1
vote
Accepted
Optimizing UITableViewCell with singleton property
Omg a lowly TableViewCell does not tell a NavigationController what to do!
Give your cell delegate methods like productCell:didTapEditButton: and set your VC as ...
1
vote
Optimizing UITableViewCell with singleton property
You are mixing controller logic into view. Breaking single responsibility principle.
Also I think you are abusing Singleton pattern. Menu view does not have to be a singleton. Having it as a ...
1
vote
Up/down arrow key commands
Don't be too concerned about the 'shortest' solution. What you want is clean code that makes sense.
So first get rid of all those magic numbers and use enumerated constants.
Now change the if/else ...
1
vote
A C++ wrapper for Apple CoreFoundation
Missing functionality.
I don't seem move assignment. Since you have move construction and copy assignment that seems a bit strange.
Also I don't see a swap function. This becomes really useful when ...
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 ...
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:
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
objective-c × 363ios × 170
game × 43
performance × 32
beginner × 27
object-oriented × 20
cocoa × 14
memory-management × 13
strings × 12
json × 11
algorithm × 10
c × 10
mvc × 10
cocoa-touch × 10
array × 9
image × 9
design-patterns × 8
interview-questions × 8
swift × 8
animation × 8
singleton × 8
core-data × 8
sprite-kit × 8
hash-map × 7
programming-challenge × 6