obj c redraw a view 60 times a sec

To redraw a view 60 times per second in Objective-C, you can make use of the CADisplayLink class. This class allows you to synchronize your code with the refresh rate of the display, which is typically around 60 frames per second.

Here's an example of how you can use CADisplayLink to achieve this:

#import <UIKit/UIKit.h>

@interface MyView : UIView
@property (nonatomic, strong) CADisplayLink *displayLink;
@end

@implementation MyView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(redraw)];
        [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    }
    return self;
}

- (void)redraw {
    // Perform your drawing code here
    [self setNeedsDisplay];
}

@end

In this example, we create a custom view class called "MyView" that inherits from UIView. In the initWithFrame: method, we initialize a CADisplayLink object and add it to the main run loop with the target set to self and the selector set to the redraw method.

The redraw method is called by the CADisplayLink object every time the display is refreshed. In this method, you can perform your custom drawing code and call setNeedsDisplay to trigger a redraw of the view.

By adding the CADisplayLink to the main run loop with NSRunLoopCommonModes, it will be automatically synchronized with the display refresh rate, ensuring that the view is redrawn approximately 60 times per second.

Remember to import the necessary UIKit framework and add an instance of MyView to your view hierarchy to see the redraw in action.

I hope this code snippet helps! Let me know if you have any further questions.