PTT
Submit
Submit
选择语言
正體中文
简体中文
PTT
MacDev
[问题] cs193p 程式问题
楼主:
angelina877
(牛牛)
2015-11-11 22:12:03
https://www.youtube.com/watch?v=ZqKbN_C4Yvg
课程影片约55分处
#import "TextStatsColorAndOutlineViewContrller.h"
@interface TextStatsColorAndOutlineViewContrller()
@property (weak, nonatomic) IBOutlet UILabel *colorfulCharacterLabel;
@property (weak, nonatomic) IBOutlet UILabel *outlineCharacterLabel;
@end
@implementation TextStatsColorAndOutlineViewContrller
-(void)setTextToAnalyze:(NSAttributedString *)textToAnalyze
{
_textToAnalyze = textToAnalyze;
if (self.view.window) [self updateUi];//如果是nil就不出现在萤幕上
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateUi];
}
-(void) updateUi
{
self.colorfulCharacterLabel.text = [[self characterWithAttribute:NSForegroundColorAttributeName] length];
self.outlineCharacterLabel.text = [[self characterWithAttribute:NSForegroundColorAttributeName] length];
}
-(NSAttributedString *)characterWithAttribute:(NSString *)attributeName
{
NSMutableAttributedString *characters = [[NSMutableAttributedString alloc ] init ];
int index = 0;
while (index < [self.textToAnalyze length]) {
NSRange range;
id value = [self.textToAnalyze attribute:attributeName atIndex:index effectiveRange: &range];
if (value) {
[characters appendAttributedString:[self.textToAnalyze attributedSubstringFromRange:range]];
index = range.location + range.length;
}
else{
index++;
}
}
return characters;
}
警告讯息:
在index = range.location + range.length;这一行
implicit conversion loses integer precision 'unsigned long' to 'int'
我的Code都照打
怎么还是会有warninghttps://www.youtube.com/watch?v=ZqKbN_C4Yvg
课程影片约55分处
#import "TextStatsColorAndOutlineViewContrller.h"
@interface TextStatsColorAndOutlineViewContrller()
@property (weak, nonatomic) IBOutlet UILabel *colorfulCharacterLabel;
@property (weak, nonatomic) IBOutlet UILabel *outlineCharacterLabel;
@end
@implementation TextStatsColorAndOutlineViewContrller
-(void)setTextToAnalyze:(NSAttributedString *)textToAnalyze
{
_textToAnalyze = textToAnalyze;
if (self.view.window) [self updateUi];//如果是nil就不出现在萤幕上
}
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateUi];
}
-(void) updateUi
{
self.colorfulCharacterLabel.text = [[self characterWithAttribute:NSForegroundColorAttributeName] length];
self.outlineCharacterLabel.text = [[self characterWithAttribute:NSForegroundColorAttributeName] length];
}
-(NSAttributedString *)characterWithAttribute:(NSString *)attributeName
{
NSMutableAttributedString *characters = [[NSMutableAttributedString alloc ] init ];
int index = 0;
while (index < [self.textToAnalyze length]) {
NSRange range;
id value = [self.textToAnalyze attribute:attributeName atIndex:index effectiveRange: &range];
if (value) {
[characters appendAttributedString:[self.textToAnalyze attributedSubstringFromRange:range]];
index = range.location + range.length;
}
else{
index++;
}
}
return characters;
}
警告讯息:
在index = range.location + range.length;这一行
implicit conversion loses integer precision 'unsigned long' to 'int'
我的Code都照打
怎么还是会有warning....
不解QQ
作者:
Esvent
(Esvent)
2015-11-11 23:12:00
因为编译的环境不同 arm64的NSInteger是long 之前是int啊说错 之前也是long 不过arm64的long是8byte 其他4byte详细可以参考Apple的document
https://goo.gl/t4Oiwe
32位元 long(4byte) <=> int(4byte) 长度相同 可直接转换64位元 long(8byte) <=> int(4byte) 长度不同 会掉资讯
继续阅读
[闲聊] 写了一个简单的网络电视 App
shinrenpan
[问题] 有人也上架图片上传失败吗
converse
[问题] IOS9.1推播问题
dp814082
[问题] wrong window size
dp814082
[问题] add custom activity type
essay1029
[问题] Xcode7/Swift建立Objective-C bridge
strife00
[问题] 有关把图片存到相簿的问题
iamsewei
[请益] 请问在发送电文与等待时做的处理?
tga123
[问题] 建置版本处理中 已经过了三天
lineseven
[问题] self用法
angelina877
Links
booklink
Contact Us: admin [ a t ] ucptt.com