Question: I have a Rails application with Resque doing background jobs on multiple servers. The jobs are different in terms of their resource needs, so I would like to limit the amount of jobs of particular type, each server can do. I want to be able to have multiple servers query the same Redis database. 

Here is the scenario:
I have Server-1 and Server-2 connected to the same Redis database.

1) Each server should take 3 "Encoding" jobs and 5 "Parsing" jobs max (8 jobs total). 

2) At a given moment Redis-server will have 10 jobs in "Encoding" queue and 12 jobs in "Parsing" queue available for Resque workers to process. I have 2 servers running, quering the same database. 

QUESTION: How can I prevent Server-1 from taking 8 "Encoding" jobs and Server-2 taking the rest? In other words, how to restrict Server-1 to taking only 3 jobs from "Encoding" queue and 5 jobs from "Parsing" queue and have Server-2 do the same? 

I want to keep the code universal so that I can deploy it to multiple servers without individual tweaking..

Answer: 
In Swift:

```swift
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        return string.isEmpty || Int(string) != nil
    }

```
swift 3

```
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
    if textField==yourTextFieldOutlet {
                if(CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: yourTextFieldOutlet.text!))){
//if numbers only, then your code here
                }
                else{
                showAlert(title: "Error",message: "Enter Number only",type: "failure")
                }
            }
    return true
    }

```