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

Warning: Category is implementing a method which will also be implemented by its primary class #2

Open
sfolador opened this issue Mar 8, 2014 · 10 comments

Comments

@sfolador
Copy link

sfolador commented Mar 8, 2014

Hi, first of all thank you for your project. It's really handy.

I get this Warning: "Category is implementing a method which will also be implemented by its primary class" and it's related to the code:

+(Class) layerClass {
    return [AUISelectiveBordersLayer class];
}

at line 29 in UIView+AUISelectiveBorder.m.

Do you think this could be a problem for App Store submission?

@adam-siton
Copy link
Owner

Hi

No, this is not a problem, I sent several apps to the App Store with this code.

Great to hear that you find the. Ode useful.

Adam

Sent from my iPad

On 8 במרץ 2014, at 12:05, Simone Folador [email protected] wrote:

Hi, first of all thank you for your project. It's really handy.

I get this Warning: "Category is implementing a method which will also be implemented by its primary class" and it's related to the code:

+(Class) layerClass {
return [AUISelectiveBordersLayer class];
}
at line 29 in UIView+AUISelectiveBorder.m.

Do you think this could be a problem for App Store submission?


Reply to this email directly or view it on GitHub.

@bagusflyer
Copy link

According to Apple's document, you should subclass instead of using category when you have this warning. But if subclass, you can't apply the effect to every UIView. (Actually not every UIView works).

@adam-siton
Copy link
Owner

Yes, Apple recommend not to use categories since it might cause problems
(in example it causes problem when you are using views who's underlying
layer is not a regular CALayer).
However, this is the only way to make this work for every UIView.

On Mon, Apr 7, 2014 at 12:36 PM, bagusflyer [email protected]:

According to Apple's document, you should subclass instead of using
category when you have this warning. But if subclass, you can't apply the
effect to every UIView. (Actually not every UIView works).

Reply to this email directly or view it on GitHubhttps://github.com//issues/2#issuecomment-39711565
.

@last-Programmer
Copy link

This seems to be broken in ios8 beta...the category layerclass is not being called.

@adam-siton
Copy link
Owner

Thanks for the heads up. I'll make the adjustments.

On Wed, Jun 18, 2014 at 12:38 AM, rbmanian75 [email protected]
wrote:

This seems to be broken in ios8 beta...the category layerclass is not
being called.

Reply to this email directly or view it on GitHub
#2 (comment)
.

@RomanTruba
Copy link

Be careful with that category, because all views in your applications will be selective-border layered. This can lead to performance issues

@daniebruwer
Copy link

OK I can confirm that its not working in iOS8, any suggestions...?

@cjgehinscott
Copy link

So I haven't been able to get this code to work so I looked into alternatives and came across this repo https://github.com/natrosoft/NAUIViewWithBorders. I think it really depends on what you are trying to do that will dictate if this works for you. Personally I had a view that had about 9 or 10 UILabels/UITextFields/UITextViews that were displaying content to the user. What I ended up doing is I used the NAUIViewWithBorders subclass on UIView and put all of my labels/textfields/textviews inside of their own UIView and made each UIView have a clear color background and just set the borders on those views. This does not crash in iOS8 and because it's not using a category it's not causing every view to be subjected to the new implementation. Hope this helps. If you need code samples as to what it looks like or any other help feel free to reach out. Happy Coding!

@adam-siton
Copy link
Owner

Looks like +(Class) layerClass is not called for some views (specifically UILabel) on ios8.
I'll try and find a way to solve this.

@gramx
Copy link

gramx commented Jul 15, 2015

On iOS 8.4 it runs for me, however the warning (Category is implementing a method which will also be implemented by its primary class) still exists.
I am new to objc so I do not understand why Apple would us a warning however from the comments it looks like its not an issue.
In other languages you can override your primary class methods with key words. Is it possible to do that here to avoid the compiler warning?

Update: Since categories work backwards to migrate the method I am not sure my last statement is still valid.

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

No branches or pull requests

8 participants