cocoa-touch

index 0 beyond bounds for empty array while getting to the documents directory

对着背影说爱祢 提交于 2019-12-25 04:57:11
问题 I use the following code to get to the documents directory. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; Why would my app be crashing with the following message? *** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array I can't see how my NSArray (immutable array) can be empty. The function is supposed to return the documents folder in an array. Any ideas? 回答1: 1) Are you

Is there a pre-iOS 4 replacement or workaround for UINib?

走远了吗. 提交于 2019-12-25 04:57:06
问题 My application features a tableview which contains some rather complex tableviewcells. Therefore, these cells have been designed in Interface Builder and are instanciated later as needed using UINib which allows just that - load the content from a nib and instanciate it as needed. But UINib is only available for iOS 4.0 and above. Before I go ahead and abandon all the 3.x users, is there a way to (easily) recreate what I'm doing using pre-iOS4 classes and methods? Thanks alot!! 回答1: You can

UISegmentedControl - how to toggle between 2 UITableViews

三世轮回 提交于 2019-12-25 04:56:04
问题 I have a tab bar based application. What is the best way to toggle between 2 different UITableView views? Should I use a wrapper view and add those 2 views to it and depending on which segment was chosen I will show the correct view? Using only one tableView will not work because the layout is different between those 2 tableviews. Thanks 回答1: I usually take a different approach: I prefer to use different dataSources for a single instance of tableView and then switching between them (usually

loading resources dynamically for iphone 3GS and 4

こ雲淡風輕ζ 提交于 2019-12-25 04:49:06
问题 Since the display resolution is different, I wonder if there is an official guide or tutorial that shows how to load images. icons, nibs, etc. dynamically for iPhone 4 and iPhone 3GS. Thanks in advance. 回答1: The official guide is here. (You'll need a developer account) Most of the time, you'll just need to make a high resolution image with a "@2x" suffix. 回答2: The iPhone Application Programming Guide has a section on Supporting High-Resolution Screens that should answer your questions. 来源:

IOS Swift handle global events

╄→尐↘猪︶ㄣ 提交于 2019-12-25 04:34:14
问题 How can I handle global events triggered by the notification centre for example in my API class I fire an event if an error response is received e.g. (500). When that event is fired an UIAlert should be displayed on what ever view controller is active, or on logout the login view controller should be presented. As far as I can see there is no easy way to get the current view controller in order to interact with it. (Note that my root view controller is NOT a navigation controller). 回答1: Is

A shot in the dark - Application bug

回眸只為那壹抹淺笑 提交于 2019-12-25 04:33:42
问题 Ok so this is gonna be a bit of a shot in the dark without you being able to see my application! I have a bug. I have a SwimmingPool class, my app passes the pool from a tableview into a detail view where you can see all the swimmingPool class fields. You can then click on the individual detail, edit it, and then save it. The 'original' pool facility is copied and passed to the view controller responsible for actually making changes. If the user presses save, the fields are copied from the

Storing data locally on iPhone

删除回忆录丶 提交于 2019-12-25 04:29:21
问题 I'm developing an iOS app, which is my graduation project.. the app is supposed to serve as a social network, where the user could connect to other users. From the data perspective the app needs to store some data locally, and it also have the ability to update these data with a remote server, i.e. the local data are snapshots of a subset of the data that located on the server.. Let's say that the user is able to connect to at most 100 other users, and he/she is also able to see their

In iOS 7.1, UISearchBar's text and placeholder properties don't work anymore

烂漫一生 提交于 2019-12-25 04:25:01
问题 Starting from iOS 7.1 , I have not been able to read the text nor set the placeholder of UISearchBar. The text property always returns nil and the search bar is always a blank white rectangle. In iOS 7.0 and below, I had no such problems. Does 7.1 require me to treat UISearchBars differently to make text and placeholder work? - (void)viewDidLoad { [super viewDidLoad]; self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)]; self.searchBar.placeholder = @

How to share an object with the entire project?

£可爱£侵袭症+ 提交于 2019-12-25 04:16:09
问题 For example, if I create an UILabel in an class, how can I use it wherever I want to? I already know how to share between two classes. But I need to call the value of an object in all my classes. Is it possible? 回答1: Is a singleton what you want? Basically a singleton is just a class that only returns the same instance no matter what. Here's a website that shows you how to do them. http://funwithobjc.tumblr.com/post/3478903440/how-i-do-my-singletons 回答2: The best way is to write it to the

ipad objective c using removeFromSuperview to remove UICollectionViewController throws an error

拈花ヽ惹草 提交于 2019-12-25 04:14:28
问题 So I'm customizing this control I found since I think it works very well except with this issue of mine: http://www.cocoacontrols.com/controls/fsverticaltabbarcontroller I wanted to load a UICOllectionViewCOntroller instead of a regular ViewController whenever an item is tapped on the sidebar. So I did this modification when selecting an item: - (void)setSelectedIndex:(NSUInteger)selectedIndex { NSLog(@"selected Index is %@", [NSNumber numberWithInt:selectedIndex]); NSLog(@"_selected Index is