@@ -68,9 +68,9 @@ it is possible to access these directly using `@objc`, ObjectiveC.jl provides a
68
68
automatically generate the appropriate ` getproperty ` , ` setproperty! ` and ` propertynames `
69
69
definitions:
70
70
71
- ``` julia
71
+ ``` julia-repl
72
72
julia> @objcproperties NSValue begin
73
- @autoproperty pointerValue:: Ptr{Cvoid}
73
+ @autoproperty pointerValue::Ptr{Cvoid}
74
74
end
75
75
76
76
julia> obj.pointerValue
@@ -82,30 +82,30 @@ property macros:
82
82
83
83
``` julia
84
84
@objcproperties SomeObject begin
85
- # simplest definition: just generate a getter,
86
- # and convert the property value to `DstTyp`
87
- @autoproperty someProperty:: DstTyp
88
-
89
- # also generate a setter
90
- @autoproperty someProperty:: DstTyp setter= setSomeProperty
91
-
92
- # if the property is an ObjC object, use an object pointer type.
93
- # this will make sure to do a nil check and return nothing,
94
- # or convert the pointer to an instance of the specified type
95
- @autoproperty someProperty:: id{DstTyp}
96
-
97
- # sometimes you may want to convert to a different type
98
- @autoproperty someStringProperty:: id{NSString} type= String
99
-
100
- # and finally, if more control is needed, just do it yourselv :
101
- @getproperty someComplexProperty function (obj)
102
- # do something with obj
103
- # return a value
104
- end
105
- @setproperty! someComplexProperty function (obj, val)
106
- # do something with obj and val
107
- # return nothing
108
- end
85
+ # simplest definition: just generate a getter,
86
+ # and convert the property value to `DstTyp`
87
+ @autoproperty someProperty:: DstTyp
88
+
89
+ # also generate a setter
90
+ @autoproperty someProperty:: DstTyp setter= setSomeProperty
91
+
92
+ # if the property is an ObjC object, use an object pointer type.
93
+ # this will make sure to do a nil check and return nothing,
94
+ # or convert the pointer to an instance of the specified type
95
+ @autoproperty someProperty:: id{DstTyp}
96
+
97
+ # sometimes you may want to convert to a different type
98
+ @autoproperty someStringProperty:: id{NSString} type= String
99
+
100
+ # and finally, if more control is needed, just do it yourself :
101
+ @getproperty someComplexProperty function (obj)
102
+ # do something with obj
103
+ # return a value
104
+ end
105
+ @setproperty! someComplexProperty function (obj, val)
106
+ # do something with obj and val
107
+ # return nothing
108
+ end
109
109
end
110
110
```
111
111
@@ -114,10 +114,10 @@ end
114
114
115
115
Julia callables can be converted to Objective-C blocks using the ` @objcblock ` macro:
116
116
117
- ``` julia
117
+ ``` julia-repl
118
118
julia> function hello(x)
119
- println (" Hello, $x! " )
120
- x+ 1
119
+ println("Hello, $x!")
120
+ x+1
121
121
end
122
122
julia> block = @objcblock(hello, Cint, (Cint,))
123
123
```
@@ -134,11 +134,11 @@ may decide to coalesce multiple conditions into a single execution, so it is pre
134
134
use ` @objcblock ` whenever possible. It is also not possible to pass any arguments to the
135
135
condition, but you can use a closure to capture any state you need:
136
136
137
- ``` julia
137
+ ``` julia-repl
138
138
julia> counter = 0
139
139
julia> cond = Base.AsyncCondition() do async_cond
140
- counter += 1
141
- end
140
+ counter += 1
141
+ end
142
142
julia> block = @objcasyncblock(cond)
143
143
```
144
144
@@ -147,7 +147,7 @@ julia> block = @objcasyncblock(cond)
147
147
148
148
ObjectiveC.jl also provides ready-made wrappers for essential frameworks like Foundation:
149
149
150
- ``` julia
150
+ ``` julia-repl
151
151
julia> using .Foundation
152
152
153
153
@@ -156,9 +156,9 @@ NSString("test")
156
156
157
157
158
158
julia> NSArray([str, str])
159
- (
160
- test,
161
- test
159
+ <__NSArrayI 0x12e69b9b0> (
160
+ test,
161
+ test
162
162
)
163
163
164
164
@@ -181,7 +181,7 @@ Dict{NSString, NSString} with 1 entry:
181
181
To see what ObjectiveC.jl is doing under the hood, you can toggle the ` tracing ` preference,
182
182
which will make the package print out the Objective-C calls it makes:
183
183
184
- ``` julia
184
+ ``` julia-repl
185
185
julia> using ObjectiveC
186
186
julia> ObjectiveC.enable_tracing(true)
187
187
[ Info: ObjectiveC.jl tracing setting changed; restart your Julia session for this change to take effect!
0 commit comments