2017/2/10lesson

Feb 10, 2017

parse-server出现[Error]: schema mismatch for feedPost.pageInfo; expected String but got Pointer<pageInfo> (Code: 111, Version: 1.14.2)
保存不进去。
原理是因为server在我们创建类的时候,为类保存了一个总纲类似的table_SCHEMA,我之前创建feedPost table的时候,总纲给pageInfo定义为string,这时候改成Pointer,那么需要做的要么是删除table_SCHEMA,要么更改里面某一条collection里的pageInfo类型啦。


NSString中提取单词 enumerateSubstringsInRange NSCharacterSet CFStringTokenizerRef
看了这篇网址给的说明http://blog.csdn.net/god_chong/article/details/49589499

function1:

NSString popo = @”Lorem __ ! @ () “” ipsum “” dolar ?~ # $ % ^ & < >{}\ |;:sit amet.”;
[popo enumerateSubstringsInRange:NSMakeRange(0, popo.length) options:NSStringEnumerationByWords usingBlock:^(NSString _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOLBOOL _Nonnull stop) {
NSLog(@”substring :%@”,substring);
NSLog(@”substringRange:%lu,length:%lu”,(unsigned long)substringRange.location,substringRange.length);
NSLog(@”enclosingRange:%lu,length:%lu \n\n”,(unsigned long)enclosingRange.location,enclosingRange.length);
}];
打印如下:
2015-11-02 17:22:07.244 AFNetWorkingDemo[8620:300513] substring :Lorem
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] substringRange:0,length:5
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] enclosingRange:0,length:6

2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] substring :__
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] substringRange:6,length:2
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] enclosingRange:6,length:11

2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] substring :ipsum
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] substringRange:17,length:5
2015-11-02 17:22:07.245 AFNetWorkingDemo[8620:300513] enclosingRange:17,length:7

2015-11-02 17:22:07.246 AFNetWorkingDemo[8620:300513] substring :dolar
2015-11-02 17:22:07.246 AFNetWorkingDemo[8620:300513] substringRange:24,length:5
2015-11-02 17:22:07.246 AFNetWorkingDemo[8620:300513] enclosingRange:24,length:33

2015-11-02 17:22:07.246 AFNetWorkingDemo[8620:300513] substring :sit
2015-11-02 17:22:07.246 AFNetWorkingDemo[8620:300513] substringRange:57,length:3
2015-11-02 17:22:07.273 AFNetWorkingDemo[8620:300513] enclosingRange:57,length:5

2015-11-02 17:22:07.273 AFNetWorkingDemo[8620:300513] substring :amet
2015-11-02 17:22:07.273 AFNetWorkingDemo[8620:300513] substringRange:62,length:4
2015-11-02 17:22:07.273 AFNetWorkingDemo[8620:300513] enclosingRange:62,length:5

function2:

CFStringRef string1 = (__bridge CFStringRef)([NSString stringWithFormat:@”Lorem ipsum dolar sit amet.”]); // Get string from somewhere
CFLocaleRef locale = CFLocaleCopyCurrent();
CFStringTokenizerRef tokenizer =
CFStringTokenizerCreate(
kCFAllocatorDefault
, string1
, CFRangeMake(0, CFStringGetLength(string1))
, kCFStringTokenizerUnitWord
, locale);
CFStringTokenizerTokenType tokenType = kCFStringTokenizerTokenNone;
unsigned tokensFound = 0;
while(kCFStringTokenizerTokenNone !=
(tokenType = CFStringTokenizerAdvanceToNextToken(tokenizer))) {
CFRange tokenRange = CFStringTokenizerGetCurrentTokenRange(tokenizer);
CFStringRef tokenValue =
CFStringCreateWithSubstring(
kCFAllocatorDefault
, string1
, tokenRange);
// Do something with the token
NSLog(@”tokenValue:%@”,tokenValue);
NSLog(@”tokenRange:%ld,%ld”,tokenRange.location,tokenRange.length);
CFShow(tokenValue);
CFRelease(tokenValue);
++tokensFound;
}
// Clean up
CFRelease(tokenizer);
CFRelease(locale);
打印如下:
2015-11-02 17:22:07.276 AFNetWorkingDemo[8620:300513] string:Lorem ipsum dolar sit amet.
2015-11-02 17:22:07.276 AFNetWorkingDemo[8620:300513] sss:Loremipsumdolarsitamet.
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenValue:Lorem
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenRange:0,5
Lorem
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenValue:ipsum
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenRange:9,5
ipsum
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenValue:dolar
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenRange:15,5
dolar
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenValue:sit
2015-11-02 17:22:07.277 AFNetWorkingDemo[8620:300513] tokenRange:23,3
sit
2015-11-02 17:22:07.278 AFNetWorkingDemo[8620:300513] tokenValue:amet
2015-11-02 17:22:07.278 AFNetWorkingDemo[8620:300513] tokenRange:28,4
amet

function3:

NSString string = @”Lorem ipsum dolar sit amet.”;
string = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray
components = [string componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSLog(@”%@”,components);
components = [components filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@”self <> ‘’”]];
NSLog(@”%@”,components);
string = [components componentsJoinedByString:@” “];
NSLog(@”string:%@”,string);
打印如下:
2015-11-02 17:22:07.275 AFNetWorkingDemo[8620:300513] (
Lorem,
“”,
“”,
“”,
ipsum,
dolar,
“”,
“”,
sit,
“”,
“amet.”
)
2015-11-02 17:22:07.275 AFNetWorkingDemo[8620:300513] (
Lorem,
ipsum,
dolar,
sit,
“amet.”
)
2015-11-02 17:22:07.276 AFNetWorkingDemo[8620:300513] string:Lorem ipsum dolar sit amet.


摘抄自大神可可的笔记https://zhuanlan.zhihu.com/p/20669823?refer=cocoanotes
想要把 UITableView 的 header 全都换成同一个效果,不用做任何 Subclassing,也不用做任何 Swizzling,直接 Appearance 搞定:
[[UILabel appearanceWhenContainedIn:[UITableViewHeaderFooterView class], nil] setTextColor:[UIColor redColor]];


想要短信 app 里面那种元素之间相互挤压的物理效果,使用 UIDynamicAnimator 就可以了,这里有一个很不错的范例:GitHub - ashfurrow/ASHSpringyCollectionView