MonobjcMonobjc Documented Class Library
SafeRetain<(Of <(<'T>)>)> Method (instance)
NamespacesMonobjcIdExtensionsSafeRetain<(Of <<'(T>)>>)(T)

Performs a safe retain operation on the given instance.

The equivalent code is:

CopyC#
if (instance != null) instance.Retain(); return instance;
Declaration Syntax
C#Visual BasicVisual C++
public static T SafeRetain<T>(
	this T instance
)
where T : Id
<ExtensionAttribute> _
Public Shared Function SafeRetain(Of T As Id) ( _
	instance As T _
) As T
[ExtensionAttribute]
public:
generic<typename T>
where T : Id
static T SafeRetain(
	T instance
)
Generic Template Parameters
T
The type of the instance
Parameters
instance (T)
The instance.
Return Value
The instance retained or null if instance was null
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type . When you use instance method syntax to call this method, omit the first parameter.
Version Information
  • Available in Monobjc Bridge: 10.6 (For Mac OS X 10.6 and later), 10.5 (For Mac OS X 10.5 and later)

Assembly: Monobjc (Module: Monobjc)