brush51
brush51

Reputation: 5771

How to put console outputs to a uitextview? Access to console logs

i want to display a UITextView in my app, which should contain all outputs from console.

Is this possible? How can i do that?

i am asking that, because i want a "debug-feature" for special beta testers.

Upvotes: 5

Views: 3693

Answers (2)

Aravindhan
Aravindhan

Reputation: 15628

You can refer this Tutorial for getting the iOS logs.

aslmsg q, m;
int i;
const char *key, *val;

q = asl_new(ASL_TYPE_QUERY);

aslresponse r = asl_search(NULL, q);
while (NULL != (m = aslresponse_next(r)))
{
    NSMutableDictionary *tmpDict = [NSMutableDictionary dictionary];

    for (i = 0; (NULL != (key = asl_key(m, i))); i++)
    {
        NSString *keyString = [NSString stringWithUTF8String:(char *)key];

        val = asl_get(m, key);

        NSString *string = [NSString stringWithUTF8String:val];
        [tmpDict setObject:string forKey:keyString];
    }

    NSLog(@"%@", tmpDict);
}
aslresponse_free(r);

Upvotes: 2

mrcoder
mrcoder

Reputation: 323

You may use to get console out put with answer at getting console output and put output to UITextView

Upvotes: 1

Related Questions