delegates

iOS Delegate method not called in NSObject class

£可爱£侵袭症+ 提交于 2020-08-10 19:21:13
问题 I want to capture a picture from the camera with no preview. Though I am able to do that with a UIViewController with the help of AVFoundation framework. But now I have to do the same without the ViewController. #Issue When I trying to do the same with a NSObject class the AVCapturePhotoCaptureDelegate is not called. TestingCamera.h #import <AVFoundation/AVFoundation.h> NS_ASSUME_NONNULL_BEGIN @interface TestingCamera : NSObject <AVCapturePhotoCaptureDelegate> { AVCaptureSession

Avoid race condition ?. operator

大憨熊 提交于 2020-06-28 05:53:05
问题 Does the ?. operator that can be used to invoke a delegate or event avoid race conditions? Eg. avoid race-condition manually: //The event-invoking method that derived classes can override. protected virtual void OnShapeChanged(ShapeEventArgs e) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. EventHandler<ShapeEventArgs> handler = ShapeChanged; if (handler

Fastest way for Get Value of a property (Reflection) in C#

江枫思渺然 提交于 2020-06-25 03:50:33
问题 I want to know what is fastest way to get value (only for this problem) from an object`s property ? after some searching I saw a post from @MarkGravell in this site He wrote this code : using System; using System.Reflection; using System.Reflection.Emit; public class Foo { public Foo(int bar) { Bar = bar; } private int Bar { get; set; } } static class Program { static void Main() { var method = new DynamicMethod("cheat", typeof(int), new[] { typeof(object) }, typeof(Foo), true); var il =