Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
github.com/aronbalog/corenavigation
Navigate between view controllers with ease. 💫
🔜 More stable version (written in Swift 5) coming soon.
These instructions will help you integrate CoreNavigation into your project.
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
CocoaPods 1.1+ is required to build CoreNavigation 1.0+.
To integrate CoreNavigation into your Xcode project using CocoaPods, specify it in your Podfile:
target '<Your Target Name>' do
use_frameworks!
pod 'CoreNavigation', '1.0.0-beta-4'
end
Then, run the following command:
$ pod install
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 CoreNavigation into your Xcode project using Carthage, specify it in your Cartfile:
github "aronbalog/CoreNavigation" == "1.0.0-beta-4"
class PersonProfileViewController: UIViewController, DataReceivable {
// DataReceivable associatedtype
typealias DataType = Person
func didReceiveData(_ data: Person) {
// configure UI with data
}
}
Navigate.present { $0
.to(PersonProfileViewController())
.withData(person)
}
Navigate.push { $0
.to(PersonProfileViewController())
.withData(person)
}
Why use the Destination
instead navigating directly to view controller?
Read about it on Medium:
Destination
struct PersonProfile: Destination, Routable {
// Destination associatedtype
typealias ViewControllerType = PersonProfileViewController
// Routable patterns
static var patterns: [String] = [
"https://myapp.com/person/:personId(.*)",
"https://myapp.com/user/:personId(.*)"
]
let personId: String
init(_ personId: String) {
self.personId = personId
}
var parameters: [String : Any]? {
return [
"personId": personId
]
}
static func resolve(context: Context<PersonProfile>) {
guard let personId = context.parameters?["personId"] as? String else {
// cancel navigation with some error
context.cancel(error: NavigationError.Destination.notFound)
return
}
// fetch person
fetchPerson(id: personId, completion: { (person: Person) in
// continue to navigation
context.complete(data: person)
}, failure: { (error: Error) in
// cancel navigation with some error
context.cancel(error: error)
})
}
}
Routable
typesIn order to use Matchable
types (String
, URL
, etc.) to navigate, every Destination
type must be registered. Think about it as internal DNS.
PersonProfile.register()
Navigate.router.register(routableType: PersonProfile.self)
Destination
type can be routable without conforming to Routable
protocol. Use this if you intend to create some kind of destination manifest and/or if route patterns are fetched from an external source:
Navigate.router.register(destinationType: PersonProfile.self, patterns: [
"https://myapp.com/person/:personId(.*)",
"https://myapp.com/user/:personId(.*)"
])
PersonProfile.self <- [
"https://myapp.com/person/:personId(.*)",
"https://myapp.com/user/:personId(.*)"
]
Settings.self <- [
"https://myapp.com/settings"
]
Destination
// present
Navigate.present { $0
.to(PersonProfile("sherlock_holmes"))
...
}
// or push
Navigate.push { $0
.to(PersonProfile("sherlock_holmes"))
...
}
// present
PersonProfile("sherlock_holmes").present { $0
...
}
// or push
PersonProfile("sherlock_holmes").push { $0
...
}
// present
PersonProfile("sherlock_holmes").present()
// or push
PersonProfile("sherlock_holmes").push()
// present
Navigate.present { $0
.to("https://myapp.com/person/sherlock_holmes")
...
}
// or push
Navigate.push { $0
.to("https://myapp.com/person/sherlock_holmes")
...
}
// present
"https://myapp.com/person/sherlock_holmes".present { $0
...
}
// or push
"https://myapp.com/person/sherlock_holmes".push { $0
...
}
// present
"https://myapp.com/person/sherlock_holmes".present()
// or push
"https://myapp.com/person/sherlock_holmes".push()
Destination
PersonProfile("sherlock_holmes").viewController { (viewController) in
// vc is `PersonProfileViewController`
}
"https://myapp.com/person/sherlock_holmes".viewController { (viewController) in
...
}
Destination
do {
let viewController = try PersonProfile("sherlock_holmes").viewController()
} catch let error {
// handle error
}
do {
let viewController = try "https://myapp.com/person/sherlock_holmes".viewController()
} catch let error {
// handle error
}
Note:
If you implement custom destination resolving, it must happen on the main thread; otherwise, an error is thrown.
URL
types can also be used to navigate or resolve view controller. Actually, any type conforming Matchable
protocol can be used.
struct Person {
let id: String
...
}
extension Person: Matchable {
var uri: String {
return "https://myapp.com/person/" + id
}
}
let person: Person = Person(id: "sherlock_holmes", ...)
// getting view controller
let personProfileViewController = try! person.viewController
// or navigating
person.present()
person.push()
// or more configurable syntax
Navigate.present { $0
.to(person)
...
}
Available in CoreNavigationTests
target.
Current release:
Please read Contributing for details on code of conduct, and the process for submitting pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.