SwiftRandom alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view SwiftRandom alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects -
SwiftGen-Storyboard
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
SwiftGen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
swift-protobuf
Plugin and runtime library for using protobuf with Swift -
Dollar
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
Result
Swift type modelling the success/failure of arbitrary operations. -
DeepDiff
🦀Amazingly incredible extraordinary lightning fast diffing in Swift -
Device
Light weight tool for detecting the current device and screen size written in swift. -
SwiftLinkPreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
Codextended
Extensions giving Swift's Codable API type inference super powers 🦸♂️🦹♀️ -
Popsicle
Delightful, extensible Swift value interpolation framework. -
Playbook
📘A library for isolated developing UI components and automatically taking snapshots of them. -
SwiftyJSONAccelerator
macOS app to generate Swift 5 code for models from JSON (with Codeable) -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
Compass
:earth_africa: Compass helps you setup a central navigation system for your application -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
Solar
A Swift micro library for generating Sunrise and Sunset times. -
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift -
Pythonic.swift
Pythonic tool-belt for Swift – a Swift implementation of selected parts of Python standard library. -
BetterSafariView
A better way to present a SFSafariViewController or start a ASWebAuthenticationSession in SwiftUI. -
SwiftyUtils
All the reusable code that we need in each project -
SwiftPlantUML
A command-line tool and Swift Package for generating class diagrams powered by PlantUML
WorkOS - The modern identity platform for B2B SaaS
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of SwiftRandom or a related project?
README
SwiftRandom
SwiftRandom is a tiny help suite for generating random data such as
- Random human stuff like: names, gender, titles, tags, conversations
- Random data types like: Int, CGFloat, Bool, UIColor, NSDate, NSURL, element in Array
Usage
func asExtension() {
Int.random(2, 77) // Random between 2-77
Int.random(2...77)
Int32.random(13, 37) // Random between 13-37
Int32.random(13...37)
Double.random()
Float.random(3.2, 4.5) // Random between 3.2-4.5
CGFloat.random()
NSDate.random()
NSDate.randomWithinDaysBeforeToday(7)
NSDate.random(between: Date().addingTimeInterval(TimeInterval(-5*24*60*60)), and:Date()) // Random date between now and 5 days ago
UIColor.random()
NSURL.random()
// Array Extensions
var someArray = ["hello", "world"]
someArray[0..<someArray.count].randomItem() // Array slice
someArray.randomItem()
// String Extensions
String.random(ofLength: 16)
String.random(minimumLength: 16, maximumLength: 32)
String.random(withCharactersInString: "abc", ofLength: 16)
String.random(withCharactersInString: "abc", minimumLength: 16, maximumLength: 32)
}
func asMethods() {
// Return random Int >= 10 and <= 20
// Example Output: 13
Randoms.randomInt(10,20)
// Return random Int32 >= 10 and <= 20
// Example Output: 13
Randoms.randomInt32(10,20)
// Returns a random 16 character long string containing alphanumeric characters
Randoms.randomString(ofLength: 16)
// Returns a random string containing alphanumeric characters ranging in length from 16 to 32.
Randoms.randomString(minimumLength: 16, maximumLength: 32)
// Returns a random 16 character long string containing the specified characters
Randoms.randomString(withCharactersInString: "abc", ofLength: 16)
// Returns a random string of length between 16 and 32 containing the specified characters
Randoms.randomString(withCharactersInString: "abc", minimumLength: 16, maximumLength: 32)
// Return random Double >= 10 and <= 20
// Example Output: 11.511219042938
Randoms.randomDouble(10,20)
// Return random Float >= 10 and <= 20
// Example Output: 17.0361
Randoms.randomFloat(10,20)
// Return random CGFloat between 1 >= and >= 0
// Example Output: 0.622616
Randoms.randomCGFloat()
// Return true 30%, false %70
// Example Output: false
Randoms.randomPercentageisOver(70)
// Return true or false
// Example Output: false
Randoms.randomBool()
// Return random NSDate today > and > today - 7.
// Example Output: 2015-10-08 03:55:09 +0000
Randoms.randomDateWithinDaysBeforeToday(7)
// Random Date since 1970
// Example Output: 1997-02-01 15:27:08 +0000
Randoms.randomDate()
// Return UIColor. Alpha channel always 1.
// Example Output: UIDeviceRGBColorSpace 0.645737 0.126625 0.52535 1
Randoms.randomColor()
// Return random NSURL
// Example Output: http://leagueoflegends.com/
Randoms.randomNSURL()
// ==================== Fake Generators for Fake Datasources ==================== //
// Return random name
// Example Output: "Megan Freeman"
Randoms.randomFakeName()
// Return random first name
// Example Output: "Megan"
Randoms.randomFakeFirstName()
// Return random last name
// Example Output: "Freeman"
Randoms.randomFakeLastName()
// Return random fake name prefixed by English honorific
// Example Output: "Dr. Megan Freeman"
Randoms.randomFakeNameAndEnglishHonorific()
// Return "Male" or "Female" as String
// Example Output: "Female"
Randoms.randomFakeGender()
// Return random conversation
// Example Output: "No! I'm tired of doing what you say."
Randoms.randomFakeConversation()
// Return random title
// Example Output: "B2 Pilot @ USAF"
Randoms.randomFakeTitle()
// Return random tag as string
// Example Output: "question"
Randoms.randomFakeTag()
// Return random currency as String
// Example Output: "EUR"
Randoms.randomCurrency()
// Return random (non-existing) gravatar as UIImage?
// The image is optional in case of network issues
Randoms.randomGravatar { (image, error) -> Void in
// Handle the image/error
}
// For consistance behaviour you can create custom Gravatar
Randoms.createGravatar(Randoms.GravatarStyle.Retro) { (image, error) -> Void in
// Handle the image/error
}
}
Requirements
- Swift version 2.0
Installation
Install via Carthage
- Create a
Cartfile
with the following specification and runcarthage update
.
github "thellimist/SwiftRandom" >= 1.0.0
- Follow the instructions to add the framework to an iOS project.
Install via CocoaPods
You can use CocoaPods to install SwiftRandom
by adding it to your Podfile
:
platform :ios, '8.0'
use_frameworks!
pod 'SwiftRandom' #Stable release for Swift 3.0
To download older version you can use
pod 'SwiftRandom', :git => 'https://github.com/thellimist/SwiftRandom.git' #Latest release for Swift 3.0
pod 'SwiftRandom', :git => 'https://github.com/thellimist/SwiftRandom.git', :branch => '2.x' #For Swift 2.3
Install Manually
- Download and drop 'Randoms.swift' in your project.
Improvement
- Feel free adding your own random data functions and sending pull requests.
Possible features:
- Random wildlife pictures (Should not include the image inside project, should load it from web when needed)
- Make OSX compatiable and add here: https://github.com/AndrewSB/awesome-osx
- Random JSON
- Random Gifs (Should not include gifs inside the project, should load it from web when needed)
- Random Videos (Should not include videos inside the project, should load it from web when needed)
- Implement
SwiftRandom
as a protocol any class can conform to (Post.random()
would give you a random post)
License
- SwiftRandom is available under the MIT license. See the LICENSE file.
Keywords
random, swift, data, generator, faker, fake, gravatar
*Note that all licence references and agreements mentioned in the SwiftRandom README section above
are relevant to that project's source code only.