title: Swift Building IP 4 address class for a iOS project
body: <p>I was trying to create my own class for IP Address. I want to use this for a iOS project. I'm trying to figure out were to put the code to put the range between 0 to 255. The separator isn't working correctly. I want it to hold a ip address like 192.168.0.1 if I enter 400.168.0.1 it should return a error or say please type a real ip address as one of the output that that something wrong. I trying to create a class that when you input a ip address it should hold in the class itself. I want make a iOS app later on that will help people figure how to distribute IP address for cisco routers and switches. basically want to make a app that helps people with CIDR ip address notations like this webpage program that I found online, but I can barely use without internet connection. <a href="http://jodies.de/ipcalc" rel="nofollow noreferrer">http://jodies.de/ipcalc</a>  if I could program a mobile application that can do what this website would be great for my line of work in networking.</p>
  
  <pre><code>import UIKit
  
  class IP4 {
      var ipA: Int?
      var ipB: Int?
      var ipC: Int?
      var ipD: Int?
  
      func fullIP() -&gt; Int {
          var parts: [Int] = []
  
          if let ipA = self.ipA {
              parts += [ipA]
          }
  
          if let ipB = self.ipB {
              parts += [ipB]
          }
  
          if let ipC = self.ipC {
              parts += [ipC]
          }
  
          if let ipD = self.ipD {
              parts += [ipD]
          }
          return parts.joined(separator: ".")
      }
  }
  
  let ipaddress = IP4()
  ipaddress.ipA = 223
  ipaddress.ipB = 9
  ipaddress.ipC = 50
  ipaddress.ipD = 60
  </code></pre>