~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/monomac/docs/en/MonoMac.Foundation/NSNotificationCenter.xml

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
}
97
97
</code>
98
98
      </example>
 
99
      <para>
 
100
 
 
101
        Starting with MonoMac 5.4, calling Dispose on the returned
 
102
        notification token will also remove the observer for you,
 
103
        making the code shorter.   For example:
 
104
 
 
105
      </para>
 
106
      <example>
 
107
        <code lang="C#">
 
108
NSObject notificationToken;
 
109
 
 
110
void Setup ()
 
111
{
 
112
        notificationToken = NSNotificationCenter.DefaultCenter.AddObserver (FooBar.ClockNotification, OnClockChange);
 
113
}
 
114
 
 
115
void OnClockChange (NSNotification notification)
 
116
{
 
117
        Console.WriteLine ("The ClockNotification message was posted");
 
118
}
 
119
 
 
120
void Teardown ()
 
121
{
 
122
        notificationToken.Dispose ();
 
123
}
 
124
</code>
 
125
      </example>
99
126
    </remarks>
 
127
    <related type="sample" href="http://samples.xamarin.com/Samples/ByGuid?guid=67b46eb2-81d9-477f-a448-18e68db1227b">AppPrefs</related>
 
128
    <related type="sample" href="http://samples.xamarin.com/Samples/ByGuid?guid=23a2571b-45eb-4889-bb67-d88937cb68c1">monocatalog</related>
100
129
  </Docs>
101
130
  <Members>
102
131
    <Member MemberName=".ctor">
110
139
        <Attribute>
111
140
          <AttributeName>MonoMac.Foundation.Export("init")</AttributeName>
112
141
        </Attribute>
 
142
        <Attribute>
 
143
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
144
        </Attribute>
113
145
      </Attributes>
114
146
      <Parameters />
115
147
      <Docs>
129
161
        <Attribute>
130
162
          <AttributeName>MonoMac.Foundation.Export("initWithCoder:")</AttributeName>
131
163
        </Attribute>
 
164
        <Attribute>
 
165
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
166
        </Attribute>
132
167
      </Attributes>
133
168
      <Parameters>
134
169
        <Parameter Name="coder" Type="MonoMac.Foundation.NSCoder" />
146
181
      <AssemblyInfo>
147
182
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
148
183
      </AssemblyInfo>
 
184
      <Attributes>
 
185
        <Attribute>
 
186
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
187
        </Attribute>
 
188
      </Attributes>
149
189
      <Parameters>
150
190
        <Parameter Name="t" Type="MonoMac.Foundation.NSObjectFlag" />
151
191
      </Parameters>
152
192
      <Docs>
153
193
        <param name="t">Unused sentinel value, pass NSObjectFlag.Empty.</param>
154
 
        <summary>Constructor to call on derived classes to skip initialization and merely allocate the object.</summary>
 
194
        <summary>Constructor to call on derived classes when the derived class has an [Export] constructor.</summary>
155
195
        <remarks>
156
 
          <para>This constructor should be called by derived classes when they completely construct the object in managed code and merely want the runtime to allocate and initialize the NSObject.   This is required to implement the two-step initialization process that Objective-C uses, the first step is to perform the object allocation, the second step is to initialize the object.   When you invoke the constructor that takes the NSObjectFlag.Empty you taking advatnage of a direct path that goes all the way up to NSObject to merely allocate the object's memory and bind the Objective-C and C# objects together.    The actual initialization of the object is up to you.</para>
157
 
          <para>This constructor is typically used by the binding generator to allocate the object, but prevent the actual initialization to take place.   Once the allocation has taken place, the constructor has to initialize the object.   With constructors generated by the binding generator this means that it manually invokes one of the "init" methods to initialize the object.</para>
158
 
          <para>It is your responsability to completely initialize the object if you chain up using the NSObjectFlag.Empty path.</para>
159
 
          <para>In general, if your constructors invokes the NSObjectFlag.Empty base implementation, then it should be calling an Objective-C init method.   If this is not the case, you should instead chain to the proper constructor in your class. </para>
160
 
          <para>The argument value is ignored and merely ensures that the only code that is executed is the construction phase is the basic NSObject allocation and runtime type registration.  Typically the chaining would look like this:</para>
 
196
          <para>This constructor should be called by derived classes when they are initialized using an [Export] attribute. The argument value is ignore, typically the chaining would look like this:</para>
161
197
          <example>
162
198
            <code lang="C#">
163
 
//
164
 
// The NSObjectFlag merely allocates the object and registers the
165
 
// C# class with the Objective-C runtime if necessary, but no actual
166
 
// initXxx method is invoked, that is done later in the constructor
167
 
//
168
 
// This is taken from MonoMac's source code:
169
 
//
170
 
[Export ("initWithFrame:")]
171
 
public UIView (System.Drawing.RectangleF frame) : base (NSObjectFlag.Empty)
172
 
{
173
 
// Invoke the init method now.
174
 
        var initWithFrame = new Selector ("initWithFrame:").Handle;
175
 
        if (IsDirectBinding)
176
 
                Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSend_RectangleF (this.Handle, initWithFrame, frame);
177
 
        else
178
 
                Handle = MonoMac.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_RectangleF (this.SuperHandle, initWithFrame, frame);
179
 
}
 
199
public class MyClass : BaseClass {
 
200
    [Export ("initWithFoo:")]
 
201
    public MyClass (string foo) : base (NSObjectFlag.Empty)
 
202
    {
 
203
        ...
 
204
    }
180
205
</code>
181
206
          </example>
182
207
        </remarks>
189
214
      <AssemblyInfo>
190
215
        <AssemblyVersion>0.0.0.0</AssemblyVersion>
191
216
      </AssemblyInfo>
 
217
      <Attributes>
 
218
        <Attribute>
 
219
          <AttributeName>System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Advanced)</AttributeName>
 
220
        </Attribute>
 
221
      </Attributes>
192
222
      <Parameters>
193
223
        <Parameter Name="handle" Type="System.IntPtr" />
194
224
      </Parameters>
328
358
      <Docs>
329
359
        <param name="observer">To be added.</param>
330
360
        <param name="aSelector">To be added.</param>
331
 
        <param name="aName">To be added.</param>
332
 
        <param name="anObject">To be added.</param>
 
361
        <param name="aName">
 
362
          <para>Optional name that you want to register with and filter delivery by this name.   Use null if you do not want filtering to take place.</para>
 
363
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
364
        </param>
 
365
        <param name="anObject">
 
366
          <para>The object that we want to receive notifications from, or null for receiving the specified notifications sent by all objects.</para>
 
367
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
368
        </param>
333
369
        <summary>Low-level add-bserver API</summary>
334
370
        <remarks>
335
371
          <para>
500
536
      </Parameters>
501
537
      <Docs>
502
538
        <param name="aName">To be added.</param>
503
 
        <param name="anObject">To be added.</param>
 
539
        <param name="anObject">
 
540
          <para>The reference object posting this notification, can be null.</para>
 
541
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
542
        </param>
504
543
        <summary>To be added.</summary>
505
544
        <remarks>To be added.</remarks>
506
545
      </Docs>
527
566
      </Parameters>
528
567
      <Docs>
529
568
        <param name="aName">To be added.</param>
530
 
        <param name="anObject">To be added.</param>
531
 
        <param name="aUserInfo">To be added.</param>
 
569
        <param name="anObject">
 
570
          <para>The reference object posting this notification, can be null.</para>
 
571
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
572
        </param>
 
573
        <param name="aUserInfo">
 
574
          <para>To be added.</para>
 
575
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
576
        </param>
532
577
        <summary>To be added.</summary>
533
578
        <remarks>To be added.</remarks>
534
579
      </Docs>
584
629
      </Parameters>
585
630
      <Docs>
586
631
        <param name="observer">To be added.</param>
587
 
        <param name="aName">To be added.</param>
588
 
        <param name="anObject">To be added.</param>
 
632
        <param name="aName">
 
633
          <para>Optional name that you registered.   Use null if you do not want filtering to take place.</para>
 
634
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
635
        </param>
 
636
        <param name="anObject">
 
637
          <para>The object that you originally registered interest in.</para>
 
638
          <para tool="nullallowed">This parameter can be <see langword="null" />.</para>
 
639
        </param>
589
640
        <summary>To be added.</summary>
590
641
        <remarks>To be added.</remarks>
591
642
      </Docs>