Tag: cocoa touch

如何检查数组值在另一个数组中不存在

我有两个不同的NSMutabelArray ArrOne和ArrTwo。 Letsay ArrOne = A,B,C和D ArrTwo = C,D,X和Y.所以我需要检查ArrTwo的值是否与ArrOne相同,如果ArrTwo与ArrOne不一样, 在这种情况下,我必须从ArrTwo中删除X和Y. 请给我一个主意。

cocoa触摸/ Xcode – 生成无NIBgraphics上下文

我的应用程序委托包含: – (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if (!window) { [self release]; return; } window.backgroundColor = [UIColor greenColor]; [window addSubview:viewController.view]; [window makeKeyAndVisible]; [window layoutSubviews]; } 这确实得到执行,显然没有错误。 窗口variables不是0所以testingif (! window)不会导致函数返回。 但是不会出现绿色背景窗口,只是默认的颜色。 在appController.m文件中,viewDidLoad方法中的代码执行。 但是CGContextRef context = UIGraphicsGetCurrentContext(); 返回null而不是真实的上下文。 我要离开什么?

iOS 9:推送/stream行视图控制器由edgesForExtendedLayout中断

在iOS 9上进行debugging时,我发现了一个奇怪的问题。在View Controller的viewDidLoad我有这样一段代码: if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) { self.edgesForExtendedLayout = UIRectEdgeNone; } 当我推动或popup一个新的视图控制器时,我注意到一个奇怪的animation。 过渡并不顺利,好像它正在显示视图控制器的“堆栈”(您可以注意到两幅图像的顶部,甚至是底部)。 我在iOS 7或iOS8上没有问题,这是新发布的iOS 9的错误还是我错过了一些东西? 还值得一提的是,我正在使用自定义animation进行推/视图控制器转换。 这里是一个重写的UINavigationController方法的例子 – (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { UIView *theWindow = self.view; [[theWindow layer] removeAllAnimations]; if (animated) { CATransition *animation = [CATransition animation]; [animation setDuration:0.25]; [animation setType:kCATransitionFade]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]]; [[theWindow layer] addAnimation:animation forKey:@""]; } [super pushViewController:viewController animated:NO]; } 编辑 […]

带有UICollectionView的NSFetchResultController与索引/单元格有关的更新和删除操作

第一次,我使用UICollectionView,我有一些困难。 特别是更新和删除单元格(将重点放在这里删除,希望NSFetchResultController ),从NSFetchResultController数据。 我在界面生成器中创build了一个自定义单元格,作为这样一个故事板的一部分: 我有一个自定义的UICollectionViewCell子类具有以下属性: @property (strong, nonatomic) IBOutlet UIButton *deleteButton; @property (strong, nonatomic) IBOutlet UITextField *textField; @property (strong, nonatomic) IBOutlet UIView *containerView; @property (strong, nonatomic) IBOutlet UIView *textFieldContainer; 在IB中,我将单元类设置为自定义类,将元素连接到自定义类的属性,并将标识设置为Cell 。 在我的集合视图视图控制器中,我设置了集合视图和fetchResultController以及相关的方法,如下所示: – (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { return [[self.fetchedResultsController sections] count]; } – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { id <NSFetchedResultsSectionInfo> sectionInfo = [self.fetchedResultsController sections][section]; return [sectionInfo numberOfObjects]; […]

iOS:在当前的模式视图控制器后面切换视图控制器?

当我启动我的应用程序,我提出了根视图控制器(目前只是一个图片),然后popup一个模态视图控制器的步行通过。 一旦用户完成了漫步,我想解除模态视图控制器,并让用户立即呈现应用程序(而不是根)的主视图控制器。 我的问题是我不知道如何去做这件事。 目前我所能做的只是将模式退回到根,然后将根视图控制器切换到主视图控制器。 这使得一个非常丑陋的过渡。 //WalkthroughViewController.m -(void)completeWalkthrough:(UIButton *)sender { // What can I do here to switch the RootViewController // to display MainViewController ? [self dismissViewControllerAnimated:YES completion:nil]; } 任何帮助表示赞赏。 谢谢。

iOS – 多个NSURLConnection下载

我试图使用NSURLConnection下载一些文件: – (void)startDownload { NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; [req addValue:@"Basic XXXXXXXXXXXXXX=" forHTTPHeaderField:@"Authorization"]; connection = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES]; } – (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)response { filepath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:save_name]; [[NSFileManager defaultManager] createFileAtPath:filepath contents:nil attributes:nil]; file = [[NSFileHandle fileHandleForUpdatingAtPath:filepath] retain]; [file seekToEndOfFile]; } – (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [file seekToEndOfFile]; [file […]

iOS使用ID3Lib来编辑NSDocsDir中的mp3文件的ID3标签

我正在使用ID3Lib示例项目来编辑mp3文件上的标题,专辑和艺术家ID3标签,一切都很好,直到我来添加一个图像(封面艺术),如果任何人有任何想法如何完成下面的代码将是伟大的: – (void)demo { nImage = [UIImage imageNamed:@"amazing-grace.jpg"];//unused NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"amazing-grace" ofType:@"jpg"]; NSString *path = [[NSBundle mainBundle] pathForResource:@"amazing-grace-10s" ofType:@"mp3"]; NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *docPath = [[docPaths objectAtIndex:0] stringByAppendingPathComponent:@"amazing-grace-10s.mp3"]; [[NSFileManager defaultManager] copyItemAtPath:path toPath:docPath error:nil]; // Read title tag ID3_Tag tag; tag.Link([path UTF8String]); ID3_Frame *titleFrame = tag.Find(ID3FID_TITLE); unicode_t const *value = […]

JSON和核心数据:我应该将JSON转换成核心数据?

我是新来的核心数据,我需要一些帮助我的项目。 我正在开发iPhone应用程序,从服务器获取JSON(餐馆信息),并在地图和表格视图上显示位置,并通过按“添加最爱”button存储最喜欢的餐馆。 现在,我只是使用NSDictionary及其function来显示表和注释数据,并使用favoriteRestaurant实体来存储喜欢的餐馆数据。 但是,我想将NSDictionary对象转换为核心数据对象(餐厅),并添加“BOOL isFavorite”属性,然后删除favoriteRestaurant实体。 设置保存已传递的餐厅对象的function,改变“添加collections”button触发的“collections”状态。 最喜欢的表格只显示已经保存的餐馆,并且是“collections”=“是”。 我想知道这是否是正确的方法来完成我想要的。 先谢谢你! 嗨,谢谢你的快速回复。 我忘了说,我也想实现MKAnnotation这个类,所以地图上的每个注释引脚属于唯一的餐厅对象。 如果我想这样做,我应该有另一个喜欢的类或核心数据实体,或者只是将其保存在餐厅表中,并使isFavorite = YES? 再次感谢你!

UICollectionView:如何处理视图加载之前和之后的更新?

在通过KVO接收更新时,我遇到更新集合视图的问题。 例如删除我执行以下操作: dispatch_async(dispatch_get_main_queue(), ^{ NSUInteger index = [self.albumObjects indexOfObject:oldObject]; NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; [self.dataSource removeObjectAtIndex:index]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; } 以上给我的错误: attempt to delete item 0 from section 0 which only contains 0 items before the update 好的…因此,我们从数据源中删除,然后返回以下错误: dispatch_async(dispatch_get_main_queue(), ^{ NSUInteger index = [self.albumObjects indexOfObject:oldObject]; NSIndexPath* indexPath = [NSIndexPath indexPathForItem:index inSection:0]; [self.collectionView deleteItemsAtIndexPaths:@[indexPath]]; [self.dataSource removeObjectAtIndex:index]; […]

将应用程序更新到最新版本后,文件不再可读

我一直在为iPad开发企业分布式应用程序大约一年。 当时我们已经发布了5个生产版本,从来没有遇到任何问题。 每当我们的用户安装新版本的旧版本,我们的核心数据迁移总是正常工作。 直到我们将video录制添加到应用程序。 我们一直在核心数据外部pipe理的数据types中存储“媒体”。 这工作正常,直到我们开始允许用户创build大型video。 于是我们发现,Core Data迁移垃圾超过〜5MB的任何文件。 在这一点上,我们推出了自己的文件pipe理scheme。 这个工作完全没有问题,我们自己写了我们自己手动把文件从Core Data中移出来,然后写入我们自己的scheme中。 这是没有问题的发布。 那么,到了推出我们的下一个function时,突然出现了一个问题。 从Xcode构build时从来没有任何问题…但是,在使用Enterprise Deployment重新部署之后,写入到以前版本中的文件系统的任何文件都突然无法读取。 如果设备插入到XCode中,文件在pipe理器中清晰可见。 但NSFileManager / NSFileHandle / NSData找不到这些文件。 他们总是报告他们经历: error: { NSFilePath = "/var/mobile/Applications/3CFB07B3-D17F-45D7-A233-4E56930D794C/Documents/ep_binary_data/9465C282-7ED2-428E-B7D3-545BCFE4DFC5"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; } 就像我说的那样,我可以使用XCode Organizervalidation该文件是否在该path上实际存在。 任何帮助将不胜感激。 整天试图弄清楚这件事,我一直把头撞到桌子上。 用于阅读的代码如下所示: NSError *err = nil; NSData *data = […]