摘要:采用RSA加密方式,主要是生成公钥和私钥,公钥用来加密,私钥用来解密,至于其中如何实现的,网上有很多原理。参见如下:https://github.com/jslim89/RSA-objcPS:生成私钥$ openssl genrsa -out private_key.pem 512生成公钥$ ope...
阅读全文
摘要:如果你想交换两个变量的值:1. 整型func swapTwoInts(inout a: Int, inout b: Int) {let temporaryA = aa = bb = temporaryA}2. 字符串func swapTwoStrings(inout a: String, inout...
阅读全文
摘要:scrollView.subviews.map { (var view) -> () in if (view is UIButton) { view.removeFromSuperview() }}
阅读全文
摘要:由于修改一些文件名字等会导致这个不工作。"Organizer" / "Projects" / 选择你的项目. "Delete" .
阅读全文
摘要:如果URL中带空格,在浏览器中可以显示,但是如果访问比如UIImage 获取图片的时候就会出现BAD URL.解决:NSString* urlText = @"70.84.58.40/projects/igolf/TipThumb/GOLF 58B.jpg";NSString* urlTextEscaped = [urlText stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
阅读全文
摘要:这个最典型的就是电话本,然后根据A-Z分组, 当然很多例子,不过现在发现一个很简洁易懂的:1. 准备数据,定义一个dictionary来显示所有的内容,这个dictionary对应的value全是数组也就是:A -> A1, A2...B -> B1, B2......NSMutableDictionary *sections;2. 创建所有的KeysBOOL found; // Loop through the books and create our keys for (NSDictionary *book in self.books) //self.books 就是包含NSD
阅读全文
摘要:IOS 6 升到 IOS7 之后出现的状况新建一个工程,删除默认的ViewController,拖拽一个TableViewController到storyboard。即使没有勾选"Extend Edges Under {Top, Bottom, Opaque} Bars"或者self.edgesForExtendedLayout=UIRectEdgeNone;self.extendedLayoutIncludesOpaqueBars=NO;self.automaticallyAdjustsScrollViewInsets=NO;UITableView都会在status ba
阅读全文
摘要:git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstategit commit -m "Removed file that shouldn't be tracked"
阅读全文
摘要:The constants for specifying the alpha channel information are declared with the CGImageAlphaInfo type but can be passed to this parameter safely.Just use a cast to suppress the warning:CGBitmapInfo bitmapInfo =(CGBitmapInfo) kBitmapInfo;
阅读全文
摘要:假设每个cell上面都有UIButton,怎么判断哪个Cell上的按钮被按下了呢?IOS6上-(IBAction)btnClick:(id)sender{ UIButton *btn = (UIButton *)sender; UITableViewCell *cell = [btn superView]; NSIndexPath *index = [self.tableView indexPathForCell:cell]; xxxx}IOS7上同样的方式你会发现btn的superView变成了UITableViewCellScrollView,那么IOS7怎么获取呢?可以按照这样的...
阅读全文
摘要:To hide status bar in any viewcontroller:-(BOOL) prefersStatusBarHidden{ return YES;}To change the status bar text to white color.set UIViewControllerBasedStatusBarAppearance to NO on .plist file first, then added this method:-(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleL...
阅读全文
摘要:mkdir ~/Sitesecho "My site works" > ~/Sites/index.html.ensudo vi /etc/apache2/httpd.conf#LoadModule php5_module libexec/apache2/libphp5.sotoLoadModule php5_module libexec/apache2/libphp5.so在/etc/apache2/下应该有一个用户配置文件,如果你是升级到Lion的你不会有,如果不存在的话就建立一个sudo vi /etc/apache2/users/.conf输入/Sites/&
阅读全文
摘要:If enable the facebook account in settings, when change account can't open the session.-(void)fbResync{ ACAccountStore *accountStore; ACAccountType *accountTypeFB; if ((accountStore = [[ACAccountStore alloc] init]) && (accountTypeFB = [accountStore accountTypeWithAccountTypeIdentifier:AC
阅读全文
摘要:rc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; rc.modalPresentationStyle = UIModalPresentationFormSheet; [self presentModalViewController:rc animated:YES]; rc.view.superview.frame = CGRectMake(0, 0, 200, 200);
阅读全文
摘要:FATAL ERROR: The persistent cache of section information does not match the current configuration. You have illegally mutated the NSFetchedResultsController's fetch request, its predicate, or its sort descriptor without either disabling caching or using +deleteCacheWithName: NSError *error =...
阅读全文
摘要:向上:A被除数,B除数。(A+B-1)/B向下:floor()
阅读全文
摘要:这样的链接:http://graph.facebook.com/coorslight不工作,但是http://graph.facebook.com/cocacola确可以,为什么呢?因为facebook设置了年龄,前面的需要17岁以上(喝酒问题)解决:http://graph.facebook.com/coorslight?access_token=xxxxxx
阅读全文
摘要:自定义Cell当然很简单,subclass UITableViewCell,分2种,一种自己定义Nib文件,一种不使用Nib文件:当然依照个人选择,我喜欢少写代码,使用Nib文件。1. 添加文件继承自 UITableViewCell。2. 使用Nib文件。添加User Interface -> View 文件,IB拖拽一个TableViewCell控件(删除原来的View)。3. 对自定义的Cell进行自定义,当然像你设计的那样的设计。4. 这里我主要说在 UITableView的delegate方法中的使用1)不使用nib文件,当然很简单了- (UITableViewCell *)ta
阅读全文
摘要:FUCK, SHIT, etc. 一系列脏话,日了等。为啥,因为烦的要命。主要是碰到了一个问题,我要在UIsearchBar的左边加一个按钮,这样UISearchBar的width就变小窄了。但是每次点击Cancel的时候,UISearBar又填充了整个视图的宽度。如下图:解决方法:-(void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController*)controller{// animate the search bar to the left ie. x=0[UIView animateWithDuration:
阅读全文