nj.
nj.

Reputation: 756

Should a global instace of a viewcontroller be owned by app delegate

Due to a bug/problem with ZBar and iOS 7 we can not create, destroy and recreate a view controller that's used for scanning. So we need to keep an permanent and global instance of it to be accessed by several different views.

In the current solution the scanner view instance is a member of the app delegate and instanciated when the application starts. When it needs to be displayed it is accessed by [[UIApplication sharedApplication] delegate].

This is a forced solution but I still want it to be as descent as possible. Is there a better place to put the scanner view controller?

Upvotes: 1

Views: 86

Answers (2)

karthika
karthika

Reputation: 4091

Better you put in .pch file,

#define MY_APP_DELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)

Upvotes: 2

Dushyant Singh
Dushyant Singh

Reputation: 721

Make a Singleton class for your scanning

Upvotes: 4

Related Questions