@Test public void returnedNSObjectIsNormallyRetained() { FromNativeConverter converter = new ObjCObjectTypeConverter(NSNumber.class); NSNumber number = Rococoa.create("NSNumber", NSNumber.class, "numberWithInt:", 45); assertRetainCount(2, number); NSNumber converted = (NSNumber) converter.fromNative(new Long(number.id().longValue()), null); assertRetainCount(3, converted); assertRetainCount(3, number); }
public T fromNative(Object nativeValue, FromNativeContext context) { Number nativeValueAsNumber = (Number) nativeValue; if (nativeValueAsNumber == null) { return null; } ID id = ID.fromLong(nativeValueAsNumber.longValue()); if (id.isNull()) { return null; } boolean shouldRetain = shouldRetainFor(context); return Rococoa.wrap(id, javaType, shouldRetain); }
ObjCObjectTypeConverter implements TypeConverter { public T fromNative(Object nativeValue, FromNativeContext context) { Number nativeValueAsNumber = (Number) nativeValue; if (nativeValueAsNumber == null) { return null; } ID id = ID.fromLong(nativeValueAsNumber.longValue()); if (id.isNull()) { return null; } boolean shouldRetain = shouldRetainFor(context); return Rococoa.wrap(id, javaType, shouldRetain); } }
ObjCObjectTypeConverter implements TypeConverter { public T fromNative(Object nativeValue, FromNativeContext context) { Number nativeValueAsNumber = (Number) nativeValue; if (nativeValueAsNumber == null) { return null; } ID id = ID.fromLong(nativeValueAsNumber.longValue()); if (id.isNull()) { return null; } boolean shouldRetain = shouldRetainFor(context); return Rococoa.wrap(id, javaType, shouldRetain); } ObjCObjectTypeConverter(Class<T> javaType); }
ObjCObjectTypeConverter implements TypeConverter { public T fromNative(Object nativeValue, FromNativeContext context) { Number nativeValueAsNumber = (Number) nativeValue; if (nativeValueAsNumber == null) { return null; } ID id = ID.fromLong(nativeValueAsNumber.longValue()); if (id.isNull()) { return null; } boolean shouldRetain = shouldRetainFor(context); return Rococoa.wrap(id, javaType, shouldRetain); } ObjCObjectTypeConverter(Class<T> javaType); Class<?> nativeType(); T fromNative(Object nativeValue, FromNativeContext context); Object toNative(Object value, ToNativeContext context); }
ObjCObjectTypeConverter implements TypeConverter { public T fromNative(Object nativeValue, FromNativeContext context) { Number nativeValueAsNumber = (Number) nativeValue; if (nativeValueAsNumber == null) { return null; } ID id = ID.fromLong(nativeValueAsNumber.longValue()); if (id.isNull()) { return null; } boolean shouldRetain = shouldRetainFor(context); return Rococoa.wrap(id, javaType, shouldRetain); } ObjCObjectTypeConverter(Class<T> javaType); Class<?> nativeType(); T fromNative(Object nativeValue, FromNativeContext context); Object toNative(Object value, ToNativeContext context);  }