Hi,
i want to use CoreGraphics.CGGradientCreateWithColors method,
it takes argument of type CFArrayRef for start and stop colors ,
but i cant instantiate CFArrayRef from NSArray
how can produce CFArrayRef ?
Hi,
here is a sample:
NSMutableArray<NSString> arr = (NSMutableArray<NSString>) NSMutableArray.arrayWithCapacity(10);
arr.add(NSString.stringWithString("ABC"));
arr.add(NSString.stringWithString("BCD"));
CFArrayRef ref = ObjCRuntime.cast(arr, CFArrayRef.class);
CoreFoundation.CFArrayApplyFunction(ref, new CFRange(0, 2), new CoreFoundation.Function_CFArrayApplyFunction() {
@Override
public void call_CFArrayApplyFunction(ConstVoidPtr s, VoidPtr ctx) {
CFStringRef ref = CRuntime.cast(s, CFStringRef.class);
NSString str = ObjCRuntime.cast(ref, NSString.class);
System.out.println(str.toString());
}
}, null);
Best Regards,
Gergely
1 Like