# CortexLib class

```cpp
#import <EmotivCortexLib/CortexLib.h>
```

Use CortexLib to initialize the Cortex library.

## start

```objectivec
+ (bool)start:(CortexStartedHandler)handler;
```

Call this static method to initialize the Cortex library. You must call it exactly once. You must call it before creating an instance of the [CortexClient class](/cortex-library-for-mobile/objective-c-api/cortexclient-class.md). The library starts asynchronously. When it is started, the library calls the handler you provided.

```objectivec
typedef void (^CortexStartedHandler)(void);
```

## stop

```objectivec
+ (void)stop;
```

Call this static method to stop the Cortex library. You must call it exactly once.

## setCortexLogHandler

```objectivec
+ (void)setCortexLogHandler:(CortexLogLevel)logLevel handler:(CortexLogHandler)handler;
```

Call this method if you want to receive the log messages from the Cortex library.

Calling this method is optional. However, if you want to call it, then you must do it before calling the method `start`.

The parameter **logLevel** controls how much log messages you will receive.

* KInfo: get all the messages
* KWarning: only get the warnings and the error messages
* KError: only get the error messages

```objectivec
typedef enum CortexLogLevel : NSUInteger {
    kInfo = 1,
    kWarning = 2,
    kError = 3
} CortexLogLevel;
```

The parameter **handler** is a callback that will receive the log messages.

```objectivec
typedef void (^CortexLogHandler)(NSString*);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emotiv.gitbook.io/cortex-library-for-mobile/objective-c-api/cortexlib-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
