/Useful-Swift-Extensions

Personally useful Swift Extensions for iOS Development

Primary LanguageSwift

Useful-Swift-Extensions

Personally useful Swift Extensions for iOS Development; cobbled together from a variety of development projects and StackOverflow posts.

  • Array+Extension - moving elements in an array from one index to another; sending elements to the front or the end of an array.

  • CALayer+Extension - sending CALayer's to the front or the back of the view stack.

  • Data+Extension - determining the image extension type of a data string representation of an image.

  • Date+Extension - returning an Int64 representation of the current time-stamp.

  • NSMutableAttribtedString+Extension - changing the color value of the whole or part of an NSMutableAttributedString.

  • NSNumber+Extension - determining a Bool value from a given number. Useful when dealing with numerical values as Bools in a JSON response.

  • Sequence+Extension - returning a given sequence with only unique items (removing duplicates).

  • String+Extension - a variety of useful functions, including:

    • Converting a string to a dictionary (useful when working with JSON)

    • Determining if a given data string is representing an image

    • Determining if a string is the URL for an image source

    • Getting an extension of a string (e.g., getting the extension value of "www.github.com")

    • Determining if a url-string is HTTP or HTTPS

  • UIApplication+Extension - determines if an app has been launched before or not; funciton for returning whatever the top-most ViewController currently is.

  • UIButton+Extension - adding a UIImage to a UIButton on the right-hand side.

  • UIColor+Extension - creating a UIColor from a hex-string or RGBA int values.

  • UIFont+Extension - creating a UIFont with a specified weight.

  • UIImage+Extension - creat a UIImage with a border of a specified width and color.

  • UILabel+Extension - creating a UILabel with a specified line height.

  • UINavigationController+Extension - convenience methods for setting a navigation bar to be transparent, to have a certain tint color, or a background color.

  • UITableView+Extension - conveninece method to scroll to the top of a UITableView.

  • URL+Extension - function for getting the image data from a specified URL.