ios杂谈

NSMutableSet *set=[NSMutableSet new];

NSMutableArray *arrayA=[@[@1,@2]mutableCopy];

[set addObject:arrayA];

NSMutableArray *arrayB=[@[@1,@2]mutableCopy];

[set addObject:arrayB];

此时set里只有一个对象,因为刚才加入的那个数组和set理已有的数组相等,所以set并不会改变NSMutableArray *arrayC=[@[@1]mutableCopy];

[set addObject:arrayC];

由于arrayC与set中已有的数组不等,所以现在set中有两个数组,其中一个是最早加入的arrayA,另一个是新加入的arrayC。

UIAlertView 类可向用户展示警告信息。当用户按下按钮关闭该视图时,需要其委托协议(delegate protocol)来处理此动作,但是,要想设置好这个委托机制,就得把创建警告视图和处理按钮动作的代码分开。

-(void)askUserQuestion{

 UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Question" message:@"What do you to do?"                                                delagate:self                                                cancelButtonTitle:@"Cancel"                                                otherButtonTitles:@"COntinue",nil];[alert show];

-(void)alertDelegate:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

if(buttonIndex==0){

[self doCancel];

}else{

[self doContinue];

}}

//NSDate的初始化方法:

-(id)init;-(id)initWithString:(NSString *)string;

-(id)initWithTimeIntervalSinceNew:(NSTimeInterval)seconds;

-(id)initWithTimeInterval:(NSTimeInterval)seconds sinceDate:(NSDate *)refDate;

-(id)initWIthTimeIntervalSinceReferceDate:(NSTimeInterval)seconds;

-(id)initWithTimeIntervalSince1970:(NSTimeInterval)seconds;

委托模式:定义一套接口,某对象若想接受另一个对象的委托,则需准守此接口,以便成为其“委托对象(delegate)”.而这“另一个对象”则可以给其委托对象回传一些信息,也可以在发生相关事件时通知委托对象。

@protocol NetworkDelegate

@optional 

-(void)networkFetcher:(NetworkFetcher *)fetcher didReceivecher:(NSData *)data;

-(void)networkFetcher:(NetworkFetcher *)fetcher didFailWitError:(NSError *)error;

-(void)networkFetcher:(NetworkFetcher *)fetcher didUpdateProgressTo:(float)progress;

@end

@interface NetworkFetcher:NSObject

@property(nonatomic,weak)iddelegate;

@end

 @implementation NetworkFetcher

-(void)setColor{

NSData *data=nil;

if([_delegate respondsToSelector:@selector(networkFetcher:didReceivecher:)]){  [_delegate networkFetcher:self didReceivecher:data];

}}

@end

@interface DataModel()

@end

@implementation DataModel

-(void)ViewDidLoad{

self.networkFetcher.delegate=self;

}

-(void)networkFetcher:(NetworkFetcher *)fetcher didReceivecher:(NSData *)data{

NSLog(@"haha ");

}

@end

字符属性可以应用于 attributed string 的文本中。

NSString *const NSFontAttributeName;(字体)

该属性所对应的值是一个 UIFont 对象。该属性用于改变一段文本的字体。

如果不指定该属性,则默认为12-point Helvetica(Neue)。

NSString *const NSParagraphStyleAttributeName;(段落)

该属性所对应的值是一个 NSParagraphStyle 对象。

该属性在一段文本上应用多个属性。如果不指定该属性,

则默认为 NSParagraphStyle 的defaultParagraphStyle 方法返回的默认段落属性。

NSString *const NSForegroundColorAttributeName;(字体颜色)

该属性所对应的值是一个 UIColor 对象。

该属性用于指定一段文本的字体颜色。如果不指定该属性,则默认为黑色。

NSString *const NSBackgroundColorAttributeName;(字体背景色)

该属性所对应的值是一个 UIColor 对象。

该属性用于指定一段文本的背景颜色。如果不指定该属性,则默认无背景色。

NSString *const NSLigatureAttributeName;(连字符)

该属性所对应的值是一个 NSNumber 对象(整数)。

连体字符是指某些连在一起的字符,它们采用单个的图元符号。

0 表示没有连体字符。1 表示使用默认的连体字符。

2表示使用所有连体符号。默认值为 1(注意,iOS 不支持值为 2)。

NSString *const NSKernAttributeName;(字间距)

该属性所对应的值是一个 NSNumber 对象(整数)。

字母紧排指定了用于调整字距的像素点数。

字母紧排的效果依赖于字体。值为 0 表示不使用字母紧排。默认值为0。

NSString *const NSStrikethroughStyleAttributeName;(删除线)

该属性所对应的值是一个 NSNumber 对象(整数)。

该值指定是否在文字上加上删除线,

该值参考“Underline Style Attributes”。默认值是NSUnderlineStyleNone。

NSString *const NSUnderlineStyleAttributeName;(下划线)

该属性所对应的值是一个 NSNumber 对象(整数)。

该值指定是否在文字上加上下划线,该值参考“Underline Style Attributes”。

默认值是NSUnderlineStyleNone。。

NSString *const NSStrokeColorAttributeName;(边线颜色)

该属性所对应的值是一个 UIColor 对象。如果该属性不指定(默认),

则等同于 NSForegroundColorAttributeName。

否则,指定为删除线或下划线颜色。

更多细节见“Drawing attributedstrings that are both filled and stroked”。。

NSString *const NSStrokeWidthAttributeName;(边线宽度)

该属性所对应的值是一个 NSNumber 对象(小数)。

该值改变描边宽度(相对于字体size 的百分比)。

默认为 0,即不改变。正数只改变描边宽度。

负数同时改变文字的描边和填充宽度。例如,对于常见的空心字,这个值通常为3.0。

NSString *const NSShadowAttributeName;(阴影)

该属性所对应的值是一个 NSShadow 对象。默认为 nil。

NSString *const NSVerticalGlyphFormAttributeName;(横竖排版)

该属性所对应的值是一个 NSNumber 对象(整数)。

0 表示横排文本。1 表示竖排文本。

在 iOS 中,总是使用横排文本,0 以外的值都未定义。

你可能感兴趣的:(ios杂谈)