NSURLCache不会在iOS8中清除存储的响应

以下是我需要清除caching并调用URL的示例函数 – (void)clearDataFromNSURLCache:(NSString *)urlString { NSURL *requestUrl = [NSURL URLWithString:urlString]; NSURLRequest *dataUrlRequest = [NSURLRequest requestWithURL: requestUrl]; NSURLCache * cache =[NSURLCache sharedURLCache]; NSCachedURLResponse* cacheResponse =[cache cachedResponseForRequest:dataUrlRequest]; if (cacheResponse) { NSString* dataStr = [NSString stringWithUTF8String:[[cacheResponse data] bytes]]; NSLog(@"data str r= %@",dataStr); NSLog(@"url str r= %@",[[[cacheResponse response] URL] absoluteString]); [cache storeCachedResponse:nil forRequest:dataUrlRequest]; [NSURLCache setSharedURLCache:cache]; } [[NSURLCache sharedURLCache] removeCachedResponseForRequest:dataUrlRequest]; […]

断言失败 – ,/ SourceCache /UIKit_Sim/UIKit-2903.2/UITableView.m:7768

我试图显示与UIToolBar UIPickerView但出现一些错误。 这是我的代码 – CGRect toolbarTargetFrame = CGRectMake(0, self.view.bounds.size.height-216-44, 320, 44); CGRect datePickerTargetFrame = CGRectMake(0, self.view.bounds.size.height-216, 320, 216); UIView *darkView = [[UIView alloc] initWithFrame:self.view.bounds]; darkView.alpha = 0; darkView.backgroundColor = [UIColor blackColor]; darkView.tag = 9; UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissDatePicker:)]; [darkView addGestureRecognizer:tapGesture]; [self.view addSubview:darkView]; UIDatePicker *picker = [[UIDatePicker alloc] init]; picker.autoresizingMask = UIViewAutoresizingFlexibleWidth; picker.datePickerMode […]

通过string设置Objective-C属性

我想知道是否有一个简单的方法来设置(或检索)一个NSString的Objective-C属性…有可能使用NSSelectorFromString ,但我想要一个更容易(和更lesshacky的方式)来做到这一点。 .. 就像是 [object setProperty:@"propertyValue" named:@"propertyName"]; 相当于: object.propertyName = @"propertyValue"; 我真的不想搞乱@"propertyName"并把它变成一个@"setPropertyName:"为NSSelectorFromString命令…我可能没有其他select,但如果有人知道一个更好的方式来做到这一点,您的帮助将不胜感激!

如何检测设备是否是iPhone 5?

可能重复: 如何检测iPhone 5(宽屏设备)? 我想添加一个新的视图到现有的ios4项目来处理新的iphone5的屏幕大小。 然而,我没有在这里testing的iPhone和我用来testing屏幕大小的代码不工作,只是想知道是否有另一种方式来检测设备types? NSLog(@"%f", [ [ UIScreen mainScreen ] bounds ].size.height); if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ if([UIScreen mainScreen].bounds.size.height == 568.0) { //move to your iphone5 storyboard [self changeView:splashScreenBIGV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH]; } else{ //move to your iphone4s storyboard [self changeView:splashScreenV viewH:splashScreenH animLength:SCREEN_CHANGE_ANIM_LENGTH]; } }

如何获取TableView中的单元格对象:(UITableView *)tableView heightForRowAtIndexPath函数?

我知道当返回heightForRowAtIndexPath时,单元格的内容。 在这个函数中,我如何获得单元格对象? – (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { } 如果我尝试这个 [tableView cellForRowAtIndexPath:indexPath] 它失败,并在无限循环中熄灭。 任何想法?

禁用UIPickerView

有没有办法使UIPickerView只读? 这意味着用户不能翻阅选项。 PS。 这与在didSelectRow方法中不传递任何东西是不一样的,因为我只想让用户看到select器在那里,而不是触摸它。

UIView.animateWithDuration swift循环animation

我完全是Xcode的新手,并试图学习Swift。 在ViewController.Swift中,我设法使一个盒子从一个点变成另一个点。 我认为这个循环会很容易,所以盒子会animation到一个点,然后animation回到原来的位置,然后再循环。 我已经设法将对象移动到一个位置,并在“完成”再次移动它,但是这不会使我循环。 这怎么能实现? 我想也许这可以工作,但我真的不知道: let boxmoves = [CGRect(x: 120, y: 220, width: 100, height: 100), CGRect(x: 120, y: 120, width: 100, height: 100)] for boxmove in boxmoves { coloredSquare.frame = boxmove } 我怎么能基于设备宽度(我假设有一些math涉及?)? Xcode的任何好的新手指定网站推荐? 亲切的问候Johan 我的代码: let coloredSquare = UIView() coloredSquare.backgroundColor = UIColor.blueColor() coloredSquare.frame = CGRect(x: 120, y: 120, width: 100, height: 100) […]

在iOS8 / Swift中为UIDatePicker设置文本颜色和字体

我试图设置UIDatePicker 字体和颜色时遇到了麻烦。 除此之外,我的应用程序中的其他一切都相当简单。 有人知道怎么做这个吗? 我正在使用Swift for iOS8 。

无法在钥匙串中存储电子邮件(KeychainItemWrapper)

我正在使用github上提供的KeychainItemWrapper的ARCified版本,我无法获得它存储电子邮件和密码。 KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"myApp" accessGroup:@"MY_APP.com.yourcompany.GenericKeychainSuite"]; [keychainItem setObject:[self.email dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecAttrAccount]; [keychainItem setObject:self.password forKey:(__bridge id)kSecValueData]; 只要我存储一封电子邮件,我就完美地工作了…没有符号(@)。 否则,我得到的错误 *** Assertion failure in -[KeychainItemWrapper writeToKeychain] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Couldn't add the Keychain Item.' 哪些来自这些线路 result = SecItemAdd((__bridge CFDictionaryRef)[self dictionaryToSecItemFormat:keychainItemData], NULL); NSAssert( result == noErr, @"Couldn't add the Keychain Item." […]

应用程序商店 – 方法Swizzling合法性

是否有任何最新的信息在App Store上是否合法? 我能find的唯一数据点就是Three20框架的改变 ,从这个通知开始: 当前发布到App Store的您的应用程序xxx正在使用method_exchangeImplementations将Apple提供的API的实现与您自己的实现交换。 由于即将发生的变化,您的应用程序中的这种行为可能会导致崩溃或iPhone OS 4.0上的用户数据丢失。 xxx使用method_exchangeImplementations与你的方法ttdealloc交换dealloc的实现。 它还交换popViewControllerAnimated方法的实现:用你的方法popViewControllerAnimated2 :. 请立即解决此问题,并将新的二进制file upload到iTunes Connect。 如果我们认为这样做是谨慎或必要的,我们可能会删除您的申请。 当我四处搜寻时,我可以find关于swizzling和应用程序商店的每一个最近的对话似乎都参考了相同的Three20事件。 该通知似乎是非常具体的,我想知道这个问题是具体的变化Three20所做的更改或如果method_exchangeImplementations普遍被禁止的问题。 还有没有其他的数据说明这种做法是否被允许? 商店中是否有开发商正在使用swizzling的应用程序? 谢谢!