1662078840
Nice threadsafe expirable cache management that can cache any object. Supports fetching from server, single object expire date, UIImageView loading etc.
CachyKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CachyKit'
then run
$ pod repo update
$ pod install
UIImageView
.import CachyKit
If you want to download and cache a file(JSON, ZIP, UIImage or any type) then simply call with a url
let cachy = CachyLoader()
cachy.loadWithURL(URL(string: "http://your_url_here")!) { [weak self] data, _ in
// Do whatever you need with the data object
}
You can also cache with URLRequest
let cachy = CachyLoader()
let request = URLRequest(url: URL(string: "http://your_url_here")!)
cachy.loadWithURLRequest(request) { [weak self] data, _ in
// Do whatever you need with the data object
}
if you want set expiry date for each object
let cachy = CachyLoader()
//(optional) if isRefresh = true it will forcefully refresh data from remote server
//(optional) you can set **expirationDate** according to your need
cachy.loadWithURL(URL(string: "http://your_url_here")!,isRefresh = false,expirationDate = ExpiryDate.everyDay.expiryDate()) { [weak self] data, _ in
// Do whatever you need with the data object
}
Clear all cache
CachyLoaderManager.shared.clear()
CachyLoader has also UIImageView extension.
//(optional) if isShowLoading is true it will show a loading indicator
imageView.cachyImageLoad("your URL", isShowLoading: true, completionBlock: { _, _ in })
It will download, cache and load UIImage into your UIImageView CachyLoader is also configurable, by calling function CachyLoaderManager.shared.configure()
// All the parametre is optional
// Here if you want set how much much memory/disk should use set memoryCapacity, diskCapacity
// To cache only on memory set isOnlyInMemory which is true by default
// You may set expiry date for all the cache object by setting expiryDate
// Your objects may not be conforming to `NSSecureCoding`, set this variable to `false`
CachyLoaderManager.shared.configure(
memoryCapacity: 1020,
maxConcurrentOperationCount: 10,
timeoutIntervalForRequest: 3,
expiryDate: ExpiryDate.everyWeek,
isOnlyInMemory: true,
isSupportingSecureCodingSaving: false
)
expiryDate parametre takes
To cache using CachyLoader is the easiest way to do, but if you want manage your caching, sycning and threading CachyKit also supports that.
Here is how you can setup some configuration options
Cachy.countLimit = 1000 // setup total count of elements saved into the cache
Cachy.totalCostLimit = 1024 * 1024 // setup the cost limit of the cache
Cachy.shared.expiration = .everyDay // setup expiration date of each object in the cache
Cachy.shared.isOnlyInMemory = false // will be cached on Memory only or both
If you want to add or fetch an object you just follow these simple steps:
//1. Create a CachyObject
let object = CachyObject(value: "HEllo, Worlds", key: "key")
// A given expiry date will be applied to the item
let object2 = CachyObject(value: "HEllo, Worlds", key: "key",expirationDate: ExpiryDate.everyDay.expiryDate())
//2. Add it to the cache
Cachy.shared.add(object: object)
//3. Fetch an object from the cache
let string: String? = Cachy.shared.get(forKey: "key")
Follow and contact me on Twitter or LinkedIn. If you find an issue, just open a ticket. Pull requests are warmly welcome as well.
If you want fix anything or improve or add any new feature you are very much welcome.
Author: Sadmansamee
Source code: https://github.com/Sadmansamee/CachyKit
License: MIT license
#swift
1600430400
Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. This is why developers are able to write safer, more reliable code while saving time. It aims to be the best language that can be used for various purposes ranging from systems programming to mobile as well as desktop apps and scaling up to cloud services.
Below here, we list down the 10 best online resources to learn Swift language.
(The list is in no particular order)
#developers corner #free online resources to learn swift language #learn swift #learn swift free #learn swift online free #resources to learn swift #swift language #swift programming
1609999986
A thoroughly researched list of top Swift developers with ratings & reviews to help find the best Swift development companies around the world.
#swift development service providers #best swift development companies #top swift development companies #swift development solutions #top swift developers #swift
1594193714
Want to create a native iOS application for your Startup?
Hire Dedicated Swift Developers for end-to-end services like development, migration, upgrade, testing, and support & maintenance. Trust HourlyDeveloper.io our Swift development team for iOS device apps that are high on performance and security.
Consult with experts:- https://bit.ly/2C5M6cz
#hire dedicated swift developers #swift developers #swift development company #swift development services #swift development #swift
1655515260
Cache
A generic caching library for Swift. Cache depends on Foundation.
This is still very much a work in progress.
Cache provides a simple Cache
protocol:
protocol Cache {
associatedtype Element
func get(key key: String, completion: (Element? -> Void))
func set(key key: String, value: Element, completion: (() -> Void)?)
func remove(key key: String, completion: (() -> Void)?)
func removeAll(completion completion: (() -> Void)?)
}
There are two (well actually three, but we'll get there) provided caches:
MemoryCache
— Backed by an NSCache
DiskCache
— Backed by files on disk using NSFileManager
Using both of these is exactly the same interface.
There is a third cache provided called MultiCache
. This combines caches.
let cache = MultiCache(caches: [memoryCache, diskCache])
cache.set(key: "foo", value: "bar")
This will write to all caches in parallel. When accessing the multi cache, it will go in order. In this example, it will try the memory cache and if there's a miss it will try the disk cache. If it were to find it in the disk cache, it will write it to all previous caches for faster future reads.
Author: soffes
Source Code: https://github.com/soffes/Cache
License: MIT license
1657310040
An assistant to manage the interactions between view and model
ModelAssistant is a mediator between the view and model. This framework is tailored to work in conjunction with views that present collections of objects. These views typically expect their data source to present results as a list of sections made up of rows. ModelAssistant can efficiently analyze model objects and categorize them in sections. In addition it updates adopted view to its delegate, based on model objects changes.
Now using modelAssitant is really easy with just two lines of codes, and delegates will be implement automatically to your collection view.
See Usage for new way of implementing modelAssistant.
Upgraded to Swift 5
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
To integrate ModelAssistant into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'ModelAssistant'
end
If you are not upgraded to Swift 4.2, use the last non-swift 4.2 compatible release:
If you are using swift 4, replace pod 'ModelAssistant'
with this:
pod 'ModelAssistant', '1.0.1' #Swift 4
If you are using swift 3, replace pod 'ModelAssistant'
with this:
pod 'ModelAssistant', '1.0.0' #Swift 3
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate ModelAssistant into your Xcode project using Carthage, specify it in your Cartfile
:
github "ssamadgh/ModelAssistant"
Run carthage update --platform iOS
to build the framework and drag the built ModelAssistant.framework
into your Xcode project.
If you prefer not to use any of the aforementioned dependency managers, you can integrate ModelAssistant into your project manually.
Open up Terminal, cd
into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init
Add ModelAssistant as a git submodule by running the following command:
$ git submodule add https://github.com/ssamadgh/ModelAssistant.git
Open the new ModelAssistant
folder, and drag the ModelAssistant.xcodeproj
into the Project Navigator of your application's Xcode project.
It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
Select the ModelAssistant.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target.
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
In the tab bar at the top of that window, open the "General" panel.
Click on the +
button under the "Embedded Binaries" section.
You will see two different ModelAssistant.xcodeproj
folders each with a ModelAssistant.framework
nested inside a Products
folder.
It does not matter which
Products
folder you choose from.
Select the ModelAssistant.framework
.
And that's it!
The
ModelAssistant.framework
is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
ModelAssistant is fully compatible with all kind of design patterns. It doesn't violate them, instead it finds its place and sit there! As a guide the position of ModelAssistant in some of famous design patterns is as follows:
Design Pattern | ModelAssistant Position |
---|---|
MVC | Controller |
MVP | Presenter |
MVVM | ViewModel |
VIPER | Presenter |
ModelAssistant is owned and maintained by the Seyed Samad Gholamzadeh. You can follow me on Twitter at @ssamadgh for project updates and releases.
ModelAssistant is released under the MIT license. See LICENSE for details.
Author: ssamadgh
Source Code: https://github.com/ssamadgh/ModelAssistant
License: MIT license