How to set up the view controller as a delegate for two things (e.g. LocationManager and Accelerometer)?

I apologize if my question title seems fundamentally uninformed. Let me explain what I'm trying to do.

I have defined the following subclass of UIViewController that launches the LocationManager and has a “Start Recording” button to save the GPS track.

Now I would also like to start the accelerometer and let the user record this.

The subclass My ViewController is the delegate of the LocationManager, so what should I use for the Accelerometer delegate? Can the same view be used, or do I need to define a preview?

Here is the interface for my subclass of UIViewController:

@interface RootViewController : UIViewController <CLLocationManagerDelegate> {
    NSMutableArray *eventsArray;
    NSManagedObjectContext *managedObjectContext;
    CLLocationManager *locationManager;
    BOOL recording;
    UILabel *pointLabel;
    UIButton *startStop;
}

-(void)toggleButton;

, , , , . , iPhone, , , :)

+3
1

, . , , , .. .

, , , :

@interface Controller : UIViewController
    <CLLocationManagerDelegate, AccelerometerDelegate>
{
    ...
}

, :

[myLocationManager setDelegate:myController];
[myAccelerometer setDelegate:myController];

. , Accelerometer LocationManager, . :)

+8

Source: https://habr.com/ru/post/1712247/


All Articles