Maen
Maen

Reputation: 10698

Post NSNotification from console

Is this possible to post a NSNotification under console, when app's paused?


Why?

I need to test the reachability of a server in my app (I'm using Reachability.h).

So, I wonder if I could post notification by myself at random moments, by pausing the program and execute

[[NSNotificationCenter defaultCenter] postNotificationName:@"kReachabilityChangedNotification"
                                                        object:nil];

on the console, stopped on the main thread, to see if my ongoing downloads are well frozen.

I could :

but I wonder if a manual post would work.

As is, the command doesn't work on console, cause apparently receiver 'NSNotificationCenter' is a forward class and corresponding @interface may not exist.


Before I try to get around this :

Upvotes: 0

Views: 430

Answers (1)

ecsos
ecsos

Reputation: 636

You can just type in the lldb debugger when paused:

expr (void)[[NSNotificationCenter defaultCenter] postNotificationName:@"kReachabilityChangedNotification" object:nil]

As for your other questions:

Good practice? You could use the network link conditioner or set up your device to test various network conditions.

See Posting on the main thread

Upvotes: 1

Related Questions