Check out the docs/index.html file to explore all useful methods.
CoreUsefulSDK uses new Swift Package Manager which is easiest way introduced for iOS projects since from the beginning.
From Xcode simply select File > Swift Packages > Add Package Dependency... and paste https://github.com/exozet/iOSCoreUsefulSDK to search field. You can specify rules according to your preferences and you are ready to use.
The library itself contains more than 100 extensions, which are not only as a placeholder, but really useful to contain.
func get(index: Int) -> Element?Returns element at the index, if index is valid.
func insert(_ nullableElement: Element?)Appends element to array if its not nil. So that, you don't need to check beforehand.
func insert(_ nullableArray: [Element]?) Appends elements into the current array.
static func + (Array<Element>, Element?) -> Array<Element>
// example usage
let newArray = ["1", "2", "3"] + "4"Inserts the element into given array by using + operator.
static func += (Array<Element>, Element?)
// example usage
var array = ["1", "2", "3"]
array += "4"Inserts the element into given array by using += operator.
var isPlaying: BoolChecks rate and error state of the player, and returns true if player conforms and started to play.
class var versionInfo: StringReturns user friendly app version string.
static func - (CGSize, CGFloat) -> CGSizeReduces the width and height with the given amount.
// How to use:
let size = CGSize(width: 5, height: 5)
let newSize = size - 3static func + (CGSize, CGFloat) -> CGSizeIncreases the width and height with the given amount.
// How to use:
let size = CGSize(width: 5, height: 5)
let newSize = size + 3static func += (CGSize, CGSize) -> CGSizeAdds right handside to left handside.
// How to use:
var size = CGSize(width: 5, height: 5)
size += CGSize(width: 3, height: 3)static func -= (CGSize, CGSize) -> CGSizeDecreases the size with the given right handside.
// How to use:
var size = CGSize(width: 5, height: 5)
size -= CGSize(width: 3, height: 3)static func += (CGSize, CGFloat) -> CGSize
static func += (CGSize, Double) -> CGSize
static func += (CGSize, Int) -> CGSizeAdds right handside to left handside.
// How to use:
var size = CGSize(width: 5, height: 5)
size += 3static func -= (CGSize, CGFloat) -> CGSize
static func -= (CGSize, Double) -> CGSize
static func -= (CGSize, Int) -> CGSizeDecreases the size with the given right handside.
// How to use:
var size = CGSize(width: 5, height: 5)
size -= 3static func + (CGPoint, CGFloat) -> CGPointIncreases the X and Y points with the given amount.
// How to use:
let point = CGPoint(x: 5, y: 5)
let newPoint = point + 3static func - (CGPoint, CGFloat) -> CGPointReduces the X and Y points with the given amount.
// How to use:
let point = CGPoint(x: 5, y: 5)
let newPoint = point - 3static func + (CGPoint, CGPoint) -> CGPointAdds two point.
// How to use:
let newPoint = CGPoint(x: 5, y: 5) + CGPoint(x: 3, y:3)static func - (CGPoint, CGPoint) -> CGPointReduces the point with the given point.
// How to use:
let newPoint = CGPoint(x: 5, y: 5) - CGPoint(x: 3, y:3)func += (CGPoint, CGPoint) -> CGPointAdds right handside to left handside.
// How to use:
var point = CGPoint(x: 5, y: 5)
point += CGPoint(x: 3, y: 3)static func -= (CGPoint, CGPoint) -> CGPointDecreases left handside with right handside.
// How to use:
var point = CGPoint(x: 5, y: 5)
point -= CGPoint(x: 3, y: 3)static func += (CGPoint, CGFloat) -> CGPoint
static func += (CGPoint, Double) -> CGPoint
static func += (CGPoint, Int) -> CGPointAdds right handside to left handside.
// How to use:
var point = CGPoint(x: 5, y: 5)
point += 3static func -= (CGPoint, CGFloat) -> CGPoint
static func -= (CGPoint, Double) -> CGPoint
static func -= (CGPoint, Int) -> CGPointDecreases the size with the given right handside.
// How to use:
var point = CGPoint(x: 5, y: 5)
point -= 3init(coordinate: CLLocationCoordinate2D)Initializes the location object with the given coordinates.
var logDescription: StringRepresents latitude and longitude information in a readable way.
static func == (CLLocationCoordinate2D, CLLocationCoordinate2D) -> BoolCLLocationCoordinate conforms equality, and gives possibility to compare two of them.
var inMeters: DoubleConverts Degrees into meters value.
func getTimeLabel() -> StringReturns readable time tabel from minutes and seconds. (e.g. XX:XX)
static func + (CMTime, TimeInterval) -> CMTimeReturns CMTime with adding specified interval.
// How to use:
let newTime = CMTime(seconds: 50, preferredTimescale: .min) + 50static func - (CMTime, TimeInterval) -> CMTimeReturns CMTime with decreasing specified interval.
// How to use:
let newTime = CMTime(seconds: 50, preferredTimescale: .min) - 50static func += (CMTime, TimeInterval) -> CMTimeAdds time interval to CMTime object.
// How to use:
var time = CMTime(seconds: 50, preferredTimescale: .min)
time += 50static func -= (CMTime, TimeInterval) -> CMTimeDecreases CMTime object with the given time interval.
// How to use:
var time = CMTime(seconds: 50, preferredTimescale: .min)
time -= 50func isSameDay(Date) -> BoolReturns true, if it belongs to the same day with the given date value.
func format(String) -> StringReturns date object with the given format as string.
var isToday: BoolReturns true if date corresponds today.
var isYesterday: BoolReturns true if date corresponds yesterday.
var isTomorrow: BoolReturns true if date corresponds tomorrow.
var isTheDayAfterTomorrow: BoolReturns true if date corresponds the day after tomorrow.
func rounded(Int) -> DoubleRounds the double to decimal places value.
var asFahrenheit: IntConverts the integer format Celcius into the Fahrenheit.
var asCelcius: IntConverts the integer format Fahrenheit into the Celcius.
func setCenter(offset: CGPoint, coordinate: CLLocationCoordinate2D, animated: Bool) -> DoubleSets center of the mapview with the given offset.
func edgePoints(dx: CGFloat, dy: CGFloat) -> EdgesConverts Edge points with the given insets.
All UI elements, have inspectable variable for the texts that might useful to have direct setter for localized string.
All services that are part of the UsefulSDK or any other service in the app level can use, LoggingManager service to pass messages.
The listener class from the app-level should be set into LoggingManager.delegate property, which also needs to conform LoggingDelegate protocol, and can receive messages via log:message:level:domain:source: method.
Each messages from the LoggingManager carry their level, e.g. importance.
/// minimum level of logs
case verbose
/// standard level of logs
case info
/// warning level
case warning
/// level for error logs
case errorIn order to messages do more sense, also all messages carry their specified domain informations, e.g. which kind of part of the application/service responsible for it.
/// app domain
case app
/// view domain
case view
/// layout domain
case layout
/// controller domain
case controller
/// routing domain
case routing
/// service domain
case service
/// network domain
case network
/// data model domain
case model
/// cache domain
case cache
/// database domain
case db
/// input/output domain
case io