is there any way to know the state of my application if it is in background mode or in foreground . Thanks
you can add a boolean when the application enter in background or enter in foreground. You have this information by using the App delegate.
According the Apple documentation, maybe you can also use the mainWindow property of your Application or the active status property of the app.
NSApplication documentation
Discussion The value in this property is nil when the app’s storyboard or nib file has not yet finished loading. It might also be nil when the app is inactive or hidden.