NSLog()存储在设备(iPhone等)? 如果是的话,在哪里?

是否应该在iTunes的最终应用程序中删除所有NSLog()调用? 在我的iOS应用程序,我有很多NSLog()进行debugging。 在上传到iTunes之前是否应该有条件地将其编码? 这是为iPhone,iPod,iPad的应用程序 谢谢。

NSDatefind最近的date到今天

我有一个sorting的NSDates数组。 有人可以帮我怎样才能find最接近当前date的数组中的date? 我需要得到最接近的date的索引,以便我可以在我的tableview中滚动到该date。 例如,如果我有2013年1月1日,2013年1月6日,2013年1月9日和2013年1月10日。我想要2013年1月6日的索引。 希望是有道理的。 谢谢您的帮助。 更新: 我正在尝试这个: NSTimeInterval interval = 0; NSUInteger indexOfDate; for (NSDate * date in m_arEventsSorted) { if(abs([date timeIntervalSinceDate:[NSDate date]]) < interval) { interval = abs([date timeIntervalSinceDate:[NSDate date]]); indexOfDate = [m_arEventsSorted indexOfObject:date]; } }

在swift中解压缩文件

如何去迅速解压缩文件? 在Objective-C中,我使用了SSZipArchive,我喜欢它。 如下面的代码所示。 我怀疑,如果我决定保持SSZipArchive, 我将不得不桥接一个Objective-C文件到我的Swift文件。 有没有更新的第三方,或更好的Apple文档在Swift中解压文件? NSString *zipPath = [self.globalFileStrucure stringByAppendingPathComponent:@"zipfile.zip"]; [data writeToFile:zipPath options:0 error:&error]; BOOL unZipped = 0; unZipped = [SSZipArchive unzipFileAtPath:zipPath toDestination:self.globalFileStrucure];

用Swift语言代表

我有两个控制器,我需要调用function的第一个控制器到第二个控制器:在第二个控制器我创build了协议和init委托类: protocol testProtocol { func testDelegate() // this function the first controllers } class SecondViewController: UIViewController { var delegate: testProtocol? …. } @IBAction func testDelegateClicked(sender : AnyObject) { delegate?.testDelegate() } 第一控制器 class ViewController:UIViewController,testProtocol { var secondController: SecondViewController = SecondViewController() override func viewDidLoad() { super.viewDidLoad() secondController.delegate = self } func testDelegate() { println("Hello delegate") }</pre> 但function没有被调用

当互联网不可用时closures应用程序

当Internet连接不可用时,我想closures我的应用程序。 我检查,但我怎样才能创build一个提醒,然后closures我的应用程序?

高内存使用率通过PHAssets循环并调用requestImageForAsset

我正在使用一个图像select器库允许用户从他们的照片库中select许多图像。 它们以PHAssets数组的PHAssets返回。 然后,我想将所有的PHAssets转换为UIImages ,并将它们写入应用程序的存储。 目前,我正在循环所有资产并同步调用requestImageForAsset 。 我的问题是,当这个循环运行的时候,内存使用率会非常高(有30个镜像,最高可达130MB)。 我想阻止这一点。 这是我的代码: for(PHAsset *asset in self.assets) { NSLog(@"started requesting image %i", i); [[PHImageManager defaultManager] requestImageForAsset:asset targetSize:PHImageManagerMaximumSize contentMode:PHImageContentModeAspectFit options:[self imageRequestOptions] resultHandler:^(UIImage *image, NSDictionary *info) { dispatch_async(dispatch_get_main_queue(), ^{ assetCount++; NSError *error = [info objectForKey:PHImageErrorKey]; if (error) NSLog(@"Image request error: %@",error); else { NSString *imagePath = [appDelegate.docsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%i.png",i]]; NSData *imageData […]

Xcode 6.4导出即席“会话已过期”

我试图导出iPhone应用程序使用Xcode 6.4,但我收到一个错误: 您的会话已过期。 请login。 当Xcode检查开发团队的开发者门户。 我已经在Xcode > Preferences > Accounts双重检查了我的凭证,并且可以为团队select“ View Details ”,并按预期查看签名标识和预configurationconfiguration文件。 我曾尝试select左下方的小刷新button,并收到相同的错误: 您的会话已过期。 请login。 我加倍检查登入开发者门户网站,没有问题。 我尝试重新启动Xcode,并能够select我的开发团队,但正确的构build开始导出,Xcode崩溃。 我注意到Xcode 7.1已经发布了。 也许Xcode 6.4不再支持? 编辑这是从崩溃的堆栈跟踪: Application Specific Information: ProductBuildVersion: 6E35b ASSERTION FAILURE in /SourceCache/DVTFrameworks/DVTFrameworks-7714/DVTFoundation/Portal/DVTDeveloperPortalDatabase.m:3277 Details: (token.team) should not be nil. Object: <DVTListDevicesOperation> Method: +operationWithSingleTeamToken:andPlatform: Thread: <NSThread: 0x7fc67ef94900>{number = 43, name = (null)} Hints: None Backtrace: 0 0x0000000105c86fda […]

使用NSString将UTF-8编码转换为ISO 8859-1编码

我有一个应用程序从服务器读取UTF-8格式的数据,但它必须显示在ISO 8859-1(Latin-1)中。 有没有Cocoa API来实现这个目标?

uiimageview中的animation图像

如何从Web服务animation图像。 我得到的代码来从bundle中animation化图像。如何从url数组加载图像 该代码附在下面 UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; animatedImageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"image1.gif"], [UIImage imageNamed:@"image2.gif"], [UIImage imageNamed:@"image3.gif"], [UIImage imageNamed:@"image4.gif"], nil]; animatedImageView.animationDuration = 1.0f; animatedImageView.animationRepeatCount = 0; [animatedImageView startAnimating]; [self.view addSubview: animatedImageView];

com.apple.WebKit.WebContent丢失113错误:无法find指定的服务

我正在使用WKWebView查看自定义HTML。 无论HTML内容如何,​​在真实设备上testing时,我收到以下错误Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service WKWebView内容加载后29秒Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service ,有时甚至会收到此错误两次。 显然,这是一个configuration问题。 我已经检查了Cookie,build议在无法发信号服务com.apple.WebKit.WebContent ,但它没有帮助 另一个问题是,是否存在可能在WKWebView中popup的所有错误代码的列表