微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

objective-c – 什么原因类别正在实施一个也将由其主要类实现的方法?

我的其他程序员从网上下载这段代码
#import "UIImage+Alpha.h"

// Private helper methods
@interface UIImage ()
- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size;
@end

@implementation UIImage (Alpha)

我有错误
什么原因是Category正在实现一个也将由其主类实现的方法

我在整个文件搜索newBorderMask,该单词只显示3次.

这只是宣布一次

@interface UIImage ()
- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size;
@end

执行一次即可

#pragma mark -
#pragma mark Private helper methods

// Creates a mask that makes the outer edges transparent and everything else opaque
// The size must include the entire mask (opaque part + transparent border)
// The caller is responsible for releasing the returned reference by calling CGImageRelease
- (CGImageRef)newBorderMask:(NSUInteger)borderSize size:(CGSize)size1 {
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();

并呼吁一次

CGImageRef maskImageRef = [self newBorderMask:borderSize size:newRect.size];

所以没有双重的声明.

所以有什么问题.

解决方法

我是 code的原作者,而Aadhira的回答是错误的.此方法的类别名称不应更改为“Alpha”,因为该方法是私有的,而不是扩展的一部分.

为了摆脱警告,最好的解决方法是给私有类别一个唯一的名称,如“Privatealpha”.

有关详细信息,请参阅this discussion.

原文地址:https://www.jb51.cc/c/112349.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐