Hot answers tagged

6 votes
Accepted

Non-concurrent write creates bottleneck

The performance might be improved if you used more efficient synchronization mechanism. The @synchronized directive is notoriously inefficient. It's pretty ...
user avatar
  • 2,117
4 votes

Form for OTP entry with six single-character text fields

Your solution to this particular problem is fine in its own way. However when it comes to scaling, it will become quite messy. Since I don't see any scope of improvement/tweaking in your approach, I ...
user avatar
4 votes
Accepted

Displaying JSON data from a server in a UICollectionView

I will address a few points that are the most important in my opinion. Be consistent. You're using URL but right after that you're also using ...
user avatar
  • 260
4 votes
Accepted

Allow UITextView to resize as the user is typing

It can actually be a lot simpler! UITextView is a UIScrollView where by default the contentSize updates to fit whatever text ...
user avatar
  • 643
3 votes
Accepted

Big Nerd Ranch Bronze Challenge: Disallow Alphabetic Characters

Two problems in your code You check if the replacement string contains at least one allowed character, so that pasting "1A" into the text field would be accepted. Instead you should check if the ...
user avatar
  • 22.4k
2 votes

Big Nerd Ranch Bronze Challenge: Disallow Alphabetic Characters

Instead of rangeOfString to check if the strings contain a ".", it will be more natural to use containsString. ...
user avatar
  • 107k
2 votes

Checking for required text fields for login

In my opinion the issue here is not the repetition of if else but the repetition of similar alert message code. For example, you could continue using ...
user avatar
  • 260
2 votes
Accepted

iOS tableView with two special rows of headers

Defensive programming (never force unwrap, no forced cast, ...) is good and important to handle "runtime problems" gracefully: Unexpected user input, failed network connections, I/O errors, and many ...
user avatar
  • 22.4k
2 votes
Accepted

UITableView allowing some kinds of requests to be deleted with swipe gestures

In your first implementation you can make deleteAction a constant if you initialize it in all cases of the switch-statement: ...
user avatar
  • 22.4k
2 votes
Accepted

Playing a sound depending on the currently displayed flash card image

You shouldn't determine the sound to play from the image displayed. Instead you should use the same piece of information to set both the image ...
user avatar
  • 406
2 votes

A quiz to practice some of the notion of the chapter four of app development with swift

First of all I want to mention that I used Swift 4.2/Xcode 10.1 to write this answer. You should have this extension in your project, ...
user avatar
1 vote

Damage or Heal based on the buttons you press

not so much but some tiny changes: DRY i just would avoid all the self.healthBarView.frame.size.width and make methods: ...
user avatar
  • 278
1 vote

Set a UITableViewAccessoryType in a single UITableViewController used for two different purposes

1 You can clean switch as: ...
user avatar
1 vote
Accepted

Simple Tip Calculator

Add access level annotations (private/public) ...
user avatar
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 ...
user avatar
1 vote
Accepted

Accessing a UIView's parent UIViewController using the UIResponder chain

Your code is correct and there is nothing wrong with checking if an optional is nil unless you actually need the value if it is not. Here is an example where the ...
user avatar
  • 321
1 vote

Road to MVC: the case of Settings Table View Controller

Not familiar with Swift at all. but still want to add some comments. the primary goal of design pattern of "MVC" is to separate the aspects involved, so that extension and modification can be done ...
user avatar
  • 137

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