All Projects → marmelroy → Objectivekit

marmelroy / Objectivekit

Licence: mit
Swift-friendly API for a set of powerful Objective C runtime functions.

Programming Languages

swift
15916 projects

Labels

Projects that are alternatives of or similar to Objectivekit

Sysbox
Sysbox repository
Stars: ✭ 596 (-29.63%)
Mutual labels:  runtime
Messagethrottle
A lightweight Objective-C message throttle and debounce library.
Stars: ✭ 710 (-16.17%)
Mutual labels:  runtime
Ringojs
RingoJS is a JavaScript platform built on the JVM and optimized for server-side applications.
Stars: ✭ 777 (-8.26%)
Mutual labels:  runtime
Druntime
Low level runtime library for the D programming language
Stars: ✭ 608 (-28.22%)
Mutual labels:  runtime
Orogene
A next-generation platform and package manager for Node.js-compatible and frontend JavaScript projects!
Stars: ✭ 695 (-17.95%)
Mutual labels:  runtime
Spirit
🙌 Play Spirit animations on the web
Stars: ✭ 719 (-15.11%)
Mutual labels:  runtime
Pl Compiler Resource
程序语言与编译技术相关资料(持续更新中)
Stars: ✭ 578 (-31.76%)
Mutual labels:  runtime
Helma
Helma web framework
Stars: ✭ 18 (-97.87%)
Mutual labels:  runtime
Reflow
A language and runtime for distributed, incremental data processing in the cloud
Stars: ✭ 706 (-16.65%)
Mutual labels:  runtime
Pry
A runtime developer console and IRB alternative with powerful introspection capabilities.
Stars: ✭ 6,351 (+649.82%)
Mutual labels:  runtime
Kube Rs
kubernetes rust client and futures controller runtime
Stars: ✭ 613 (-27.63%)
Mutual labels:  runtime
Runq
run regular Docker images in KVM/Qemu
Stars: ✭ 616 (-27.27%)
Mutual labels:  runtime
Runtime
A Swift Runtime library for viewing type info, and the dynamic getting and setting of properties.
Stars: ✭ 736 (-13.11%)
Mutual labels:  runtime
Typescript Is
Stars: ✭ 595 (-29.75%)
Mutual labels:  runtime
Llamalang
Repository for the Llama Programming Language. Work In Progress
Stars: ✭ 6 (-99.29%)
Mutual labels:  runtime
Reflection
DEPRECATED
Stars: ✭ 592 (-30.11%)
Mutual labels:  runtime
Raftlib
The RaftLib C++ library, streaming/dataflow concurrency via C++ iostream-like operators
Stars: ✭ 717 (-15.35%)
Mutual labels:  runtime
Runtimemeshcomponent
Unreal Engine 4 plugin component for rendering runtime generated content.
Stars: ✭ 903 (+6.61%)
Mutual labels:  runtime
Data Collection Dotnet
Data collection application built using the .NET Runtime SDK.
Stars: ✭ 17 (-97.99%)
Mutual labels:  runtime
Stcobfuscator
iOS全局自动化 代码混淆 工具!支持cocoapod组件代码一并 混淆,完美避开hardcode方法、静态库方法和系统库方法!
Stars: ✭ 740 (-12.63%)
Mutual labels:  runtime

ObjectiveKit - Swift friendly ObjC-Runtime functions

Build Status Version Carthage compatible

ObjectiveKit

ObjectiveKit provides a Swift friendly API for a set of powerful Objective C runtime functions.

Usage

To use ObjectiveKit:

Import ObjectiveKit at the top of your Swift file:

import ObjectiveKit

The next step is to create an ObjectiveClass object typed for the class you want to modify or introspect:

let viewClass = ObjectiveClass<UIView>()

If using ObjectiveKit on a custom Swift class, make sure that it inherits at some point from NSObject and that it is exposed to the Objective C runtime using the @objc flag.

Introspection

You can learn more about classes at runtime with these handy introspection methods:

let mapViewClass = ObjectiveClass<MKMapView>()
let ivars = mapViewClass.ivars // An array of ivars.
let selectors = mapViewClass.selectors // An array of selectors.
let properties = mapViewClass.properties // An array of properties.
let protocols = mapViewClass.protocols // An array of protocols.

Modifying classes at runtime

Add a pre-existing selector from another class to your ObjectiveClass:

let viewClass = ObjectiveClass<UIView>()
viewClass.addSelector(#selector(testSelector), from: self.classForCoder)
let view = UIView()
view.perform(#selector(testSelector))

Add a custom method by providing the implementation with a closure:

let viewClass = ObjectiveClass<UIView>()
viewClass.addMethod(closureName, implementation: {
    print("hello world")
})
let view = UIView()
view.performMethod(closureName)

ObjectiveKit also supports exchanging selectors in the same class:

let viewClass = ObjectiveClass<UIView>()
viewClass.exchangeSelector(#selector(UIView.layoutSubviews), with: #selector(UIView.xxx_layoutSubviews))

Creating classes at runtime

Lastly, you can also create a custom ObjC class at runtime:

let runtimeClass = RuntimeClass(superclass: UIView.self)
runtimeClass.addIvar(ivarName, type: .Float)
let runtimeObject = runtimeClass.allocate()
runtimeObject.setValue(4.0, forKey: ivarName)

Setting up

Setting up with CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
pod 'ObjectiveKit', '~> 0.2'

Setting up with Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate ObjectiveKit into your Xcode project using Carthage, specify it in your Cartfile:

github "marmelroy/ObjectiveKit"

Inspiration

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].