Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes the [UIApplication sharedApplication] call only if possible #29

Merged
merged 3 commits into from
Jun 12, 2017

Conversation

insanoid
Copy link
Contributor

[UIApplication sharedApplication] call breaks in the extensions, the change allows the library to be included in extensions without problems.

@FabrizioBrancati
Copy link
Owner

Great! Are you currently using it within an extension?

@insanoid
Copy link
Contributor Author

I have a framework in my project which is used in both iOS app and the today extension, the framework has BFKit as a dependency. The project did not compile due to[UIApplication sharedApplication] call in the code, I had to exclude the file manually from being included in the BFKit-Pods to make it work. Everything works fine out of the box with this fix :)

@insanoid insanoid changed the title Makes the [UIApplication sharedApplication] only if possible Makes the [UIApplication sharedApplication] call only if possible May 30, 2017
Copy link
Owner

@FabrizioBrancati FabrizioBrancati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss the other piece of code, and then check the Allow app extension API only in the Xcode project.


if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {

UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use spaces instead of tabs.

if ((NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1) && UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) {

UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait;
if([UIApplication instancesRespondToSelector:@selector(sharedApplication)]){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a more useful piece of code:

Class UIApplicationClass = NSClassFromString(@"UIApplication");
if(!UIApplicationClass || ![UIApplicationClass respondsToSelector:@selector(sharedApplication)]) {
    orientation = [[[UIApplication class] performSelector:@selector(sharedApplication)] statusBarOrientation];
}

What do you think?

UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;


UIInterfaceOrientation orientation = UIInterfaceOrientationPortrait;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as UIScreen+BFKit.m.

@insanoid
Copy link
Contributor Author

I think the changes make sense, I will make the changes!

@FabrizioBrancati
Copy link
Owner

News about it? 😄

@insanoid
Copy link
Contributor Author

Made the changes requested! Sorry for the delay.

@FabrizioBrancati
Copy link
Owner

Thanks and don't worry about the delay 😉
Do you have time to make the same pull request to BFKit-Swift?

@FabrizioBrancati FabrizioBrancati merged commit d7a6fa9 into FabrizioBrancati:master Jun 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants