kostiakoval / mirror Goto Github PK
View Code? Open in Web Editor NEWSwift objects Reflection
License: MIT License
Swift objects Reflection
License: MIT License
You have realized the following functions,thanks:
mirror.isClass
mirror.isStruct
But we may need more good features, such as:
mirror.isArray
mirror.isOptional
Something like this would be great:
struct Person {
let name: String
var age: Int
}
var person = Person(name: "Jon", age: 27)
var mirror = Mirror(person)
// make some changes to mirror
var person2 = Person(mirror: mirror) // a modified version of Jon
When I get a Mirror child I want to be able to use all the same methods as on original mirror
Example:
struct A {
let a = 10
}
struct B {
let x = [1, 2, 3]
let a: A()
let m = Mirror(B())
let ar = m.children[0]
ar.isArray
... etc
Add ability to set or update values of a mirrored instance,
var mirror = Mirror(...)
mirror["name"] = "Jon"
for example,i have a Class,
Class Person{
var name: String
var age: Int
var friend: [Person]
}
you had support the properties’s normal types
but, if properties’s type is [CustomClass], or [CustomClass]? ,your type is not Accurate
can you add a isArray for properties?
english is pool, sorry,,,,,,,thanks!!!!!!!
Not supported for Swift 2.0.
Thanks~
An updated Swift 2.0 branch would be fantastic.
Great work!
if my class has any optional properties,your typesShortName is not work well:
such as:
class Person{
var name: String?
var age: Int?
var dog: Dog?
var dogs: [Dog]?
}
class Dog {
}
then,i use Mirror,
let p1 = Person()
let mirror = Mirror(p1)
println(mirror.typesShortName)
print msg like this:
[String>, Int>, Dog>, Dog>>]
i want,the result is like this:
[String, Int, Dog, [Dog]]
or
[String, Int, Dog, Array]
oh, i need optional property, and optional Array property,can you support it ?? thank you!!!
Hello!
Today I stuck with an issue after swift-2-old branch was dropped. Some Mirror's declaration don't work anymore, Ex:
if let value = itemMirror[param] where value is String {
return value as? String
} (type Mirror doesn't have subscript members))
https://gyazo.com/9547f3b03852993d1d49b675ad0f3a44
What can be the reason? Thank you.
you see,
a Class ,has it’s properties,but,to get it’s properties,i need init a instance.
can you support Mirror a Class directly?
like this:
let mirror = Mirror(Student)
thank you!!!
With your mirror framework, is it possible to get the Element type of an empty array?
let a:Array = []
And then get String somehow?
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.