swifterswift / swifterswift Goto Github PK
View Code? Open in Web Editor NEWA handy collection of more than 500 native Swift extensions to boost your productivity.
Home Page: https://swifterswift.com
License: MIT License
A handy collection of more than 500 native Swift extensions to boost your productivity.
Home Page: https://swifterswift.com
License: MIT License
error when using this lib with a custom uicontrol.
complaining about Overriding non-open var outside defining module.
Use Cocoapods Subspecs to divide the project into smaller sub projects so users can install everything or only what they need.
Suggested Subspecs
Change versioning to match Swift versioning.
example: next major release will be SwifterSwift 4.0.
The following method is missing:
drop(while condition: (Element) -> Bool)
Drop elements of Array while condition is true.
type: Mutating Method.
parameters:
condition: condition to evaluate each element against.
availability: iOS 8+ tvOS 9+ watchOS 3+ macOS 10.10+.
Please update, thank you.
Hi, i can't install with SPM...
using .Package(url: "https://github.com/SwifterSwift/SwifterSwift.git", versions: Version(1,4,0)..<Version(2, .max, .max))
i got this error:
Cloning https://github.com/SwifterSwift/SwifterSwift.git
error: The dependency graph could not be satisfied. The package (https://github.com/SwifterSwift/SwifterS
wift.git) with version tag in range (1.4.0..<2.9223372036854775807.9223372036854775807) is not found. Fou
nd tags ([1.0.2])
and with .Package(url: "https://github.com/SwifterSwift/SwifterSwift.git", majorVersion: 1, minor: 6)
i got something similar
I think the project should be split into independent projects: CocoaExtensions and DataStructure extension. So the last could be reusable everywhere and not just for iOS. It is different type of expertise to write UIKit extensions and Data Structure ones. It is difficult achieve excellence in both.
Since Swift 3 introduce Package Manager, any plans to support?
Currently test coverage is quite low, with a bunch of extension files not being tested at all.
Though there is no way to display a fancy coverage status badge in the readme it would still be nice to increase it. I don't have time to look into it right now but I would leave issue hanging around for others to see.
If someone feels like earning some cheap OS karma and get started on collaborating here it would be the simplest way to do it.
Hello @omaralbeik . I have been away for a while but could not find time for contributing recently. Just found out that Apple is including OS projects into its Swift source compatibility testing. Maybe you would be interested in joining it? Unfortunately in the nearest future I will not have time to look into it.
Hey, everyone! SwifterSwift is looking for new contributors!
You can contribute to the project in a variety of ways:
If you're new to Open Source or Swift the SwifterSwift community is a great place to get involved.
No contribution is too small.
If you have any questions or need help getting started -- feel free to let me know!
Hi,
For iOS projets it's will be great to make your component Carthage compatible
Take a look at these articles:
On your README.md
add on top and add section for the installation with Carthage.
i miss the implementation here:
public var indexPathForLastItem: IndexPath? {
guard numberOfSections > 0 else {
return nil
}
return nil
}
should be:
return IndexPath(row: indexPathForLastItem(in: lastSection), section: lastSection)
The descriptions for https://github.com/omaralbeik/SwifterSwift/wiki/uialertcontroller-extensions addAction and addTextField are reversed.
naming should be equal to other inSection
parameter namings
this:
public func indexPathForLastRow(in section: Int) -> IndexPath? {
should be:
public func indexPathForLastRow(inSection section: Int) -> IndexPath? {
pod search SwifterSwift
[!] Unable to find a pod with name, author, summary, or description matching SwifterSwift
In the latest version Xcode is complaining about Int not having a static function called randomBetween. After looking at the source code I found that it is changed from Int.randomBetween(min: 5, max: 25)
to Int.random(between: 5, max: 25)
. This change is not yet documented in your documentation.
I would also like to suggest tweaking the syntax to the following for nicer readability:
public static func random(between min: Int, and max: Int) -> Int {
return random(inRange: min...max)
}
This would result in usage as Int.random(between: 5, and: 25)
current implementation is wrong:
public var indexPathForLastRow: IndexPath? {
guard numberOfRows > 0 else {
return nil
}
return IndexPath(row: numberOfRows - 1, section: lastSection)
}
it should be:
return IndexPath(row: indexPathForLastRow(in: lastSection), section: lastSection)
[1, 2, 3, 4, 5].item(at: 2) -> 3
[1.2, 2.3, 4.5, 3.4, 4.5].item(at: 3) -> 3.4
["h", "e", "l", "l", "o"].item(at: 10) -> nil
//bug
["h"].item(at: 1) -> error, should be nil
["h", "e"].item(at: 2) -> error, should be nil
xcode: 8.3
swift: 3.1
swifterswift: 1.6.3
More fancy badges needed ;)
public var iso8601String: String {
// https://github.com/justinmakaila/NSDate-ISO-8601/blob/master/NSDateISO8601.swift
let dateFormatter = DateFormatter()
dateFormatter.locale = .posix
dateFormatter.timeZone = TimeZone(abbreviation: "GMT")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
return dateFormatter.string(from: self).appending("Z")
}
DateExtensions.swift:215:27: Type 'Locale!' has no member 'posix'
I was looking into codecov report to check how well the code is tested. But I found some disparity between codecov report and Xcode coverage report. For example look at the case of UISliderExtensions.
This is the codecov report for UISliderExtension where completion handler is not covered by test.
But when I run the same test in Xcode it is giving the following result where test coverage is 100%
Did anybody know why this disparity happens? Is it a bug with Codecov? Is there anything to do with xcpretty in travis file? Because following link says broken codecov with xcpretty.
codecov/example-swift
As I know, In Objective-C, Extension functions often write with a fix prefix. like "sd_xxx". I think swift extension should be do it as the same to forbidden conflict to other's extension?
@pawurb Could you please help adding the targets and the initial setup, then I can check all extensions compatibility with macOS.
Thank you in advance!
There's a typo on the UINavigationItem Extensions page. The word navigation in the description column is misspelled.
I see many methods here in extension have o(n^2) when is possible o(n)
SwifterSwift has conflict with DateTools
It would be nice if you could update the podspec to allow usage of this in a tvOS project as well.
Thanks,
pieter
In DateExtensions, for property 'year', why is the 'second' parameter set to newValue ?
Is this a mistake?
public var year: Int {
get {
return calendar.component(.year, from: self)
}
set {
self = Date(calendar: calendar, timeZone: timeZone, era: era, year: newValue, month: month, day: day, hour: hour, minute: minute, second: newValue, nanosecond: nanosecond)
}
}
M_PI have to changed to Double.pi
I found the functions in UITableView
and UICollectionView
extensions for dequeue cell have the prefix deque
like the following:
public func dequeReusableCell<T: UITableViewCell>(withClass name: T.Type, for indexPath: IndexPath) -> T
, not dequeue
. Is this a typo or for some reason?
Given the code:
public var nearestHourQuarter: Date {
...
public var nearestHalfHour: Date {
Shouldn't the first function be named "nearestQuarterHour", to match nearestHalfHour? Truthfully, when I was reading the code, I thought the function was named incorrectly even before I got to the second function. It just seems like it would be better to be consistent.
Currently build is displayed as passing but looking at the travis logs https://travis-ci.org/omaralbeik/SwifterSwift tests are not executing. Looks like the following commit broke travis config: e1d7bc4
Should use o(n)
The property returns true is it's not visible. Is that intended?
While adding the SS prefix to all extensions will make them less readable, it could bring more compatibility with 3rd party libraries
Example:
[1, 2, 3].ssRandomItem
// or
[1, 2, 3].ss.randomItem
instead of:
[1, 2, 3].randomItem
Seems like fadeIn is setting the alpha to 0 and fadeOut is setting the alpha to 1. Is that correct?
This method will reset all other transformations applied to the view. UIView rotate(byAngle behaves differently
I found something wrong in the document.
NSAttributedString extensions link to nothing
UIAlertController extensions link to NSAttributedString extensions
public var segmentTitles: [String?]
public var segmentImages: [UIImage?]
The implementation currently returns an empty array in the case where no titles exist.
I think it would be better to either:
a) Return an optional Array
b) Return an Array of non-optional elements
This would also eliminate double optional values from using .first property on the array
let doubleOptional = UISegmentedControl().segmentTitles.first
I would also like to remove the use of the while loops from the implementation of these properties.
I think its "swiftier" to use a for in range
loop
so we don't have to keep track of and increment our own index.
Currently with while loop
public var segmentTitles: [String?] {
get {
var titles: [String?] = []
var i = 0
while i < numberOfSegments {
titles.append(titleForSegment(at: i))
i += 1
}
return titles
}
set {
removeAllSegments()
for (index, title) in newValue.enumerated() {
insertSegment(withTitle: title, at: index, animated: false)
}
}
}
With for in range loop:
public var segmentTitles: [String?] {
get {
var titles: [String?] = []
for i in 0..<numberOfSegments {
titles.append(titleForSegment(at: i))
}
return titles
}
set {
removeAllSegments()
for (index, title) in newValue.enumerated() {
insertSegment(withTitle: title, at: index, animated: false)
}
}
}
If anyone has some thoughts on this let me know. I'd like to make any changes under the same commit for testing of this class.
the naming should be equal as other inSection
parameter naming:
public func indexPathForLastItem(in section: Int) -> IndexPath? {
should be
public func indexPathForLastItem(inSection section: Int) -> IndexPath? {
In DateExtensions:
dates don't have calendars. Adding a calendar property to Date that simply returns Calendar.current is misleading and also redundant.
instead of // and many others!
i would like to see a full doc of all functions and extensions
and mandatory for new pull requests
Then use - let someString = String(" 123 ").trimmed
have error - Value of type "String?" has no member 'trimmed'
Why?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.