nsarray

swift array.removeAtIndex error

时间秒杀一切 提交于 2019-12-25 06:56:39
问题 How come I'm getting the error "NSArray does not have a member named 'removeAtIndex'. How can I fix this? The error is on the fourth last line. Sorry if my question is stupid, I'm fairly new to programming. I appreciate all the help I get. import Foundation let userDefaults = NSUserDefaults.standardUserDefaults() func isAppAlreadyLaunchedOnce()->Bool{ let defaults = NSUserDefaults.standardUserDefaults() if let isAppAlreadyLaunchedOnce = defaults.stringForKey("isAppAlreadyLaunchedOnce"){

Swift - Search using UISearchController and NSPredicate with an array of structs

核能气质少年 提交于 2019-12-25 06:47:05
问题 Currently I'm trying to set up a search bar for my tableView. I want to filter the user's input with NSPredicate to display filtered data from an array of struct objects. But when I try to call .filteredArrayUsingPredicate() on such an array, I get the following error [Course] is not convertible to 'NSArray' . Below is my code and a link to the repo. I'm also open to any better methods of approach. import UIKit import SwiftyJSON class CourseTableViewController: UITableViewController,

Objective C Dynamic NSDictionary for UI Table View divided by Section Headers

孤街醉人 提交于 2019-12-25 05:33:15
问题 So this is based off of my question here objective c when to use NSDictionary instead of NSArray Apologies for the noob questions. I just started learning objective c and I'm really confused. - (void)viewDidLoad { [super viewDidLoad]; headers = [NSArray arrayWithObjects:@"Header Section 1 (H1)", @"Header Section 2 (H2)", nil]; events = [NSArray arrayWithObjects:@"H1 Content 1", @"H1 Content 2", nil]; myInfo = [NSArray arrayWithObjects:@"H2 Content 1", @"H2 Content 2", @"H2 Content 3", nil];

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

How to properly pass NSArray / NSMutableArray from one UIViewController to another

痞子三分冷 提交于 2019-12-25 04:53:43
问题 An iphone app I'm working on is terminating periodically ... and I have a feeling it is because of how I'm accessing a shared NSArray amongst several view controllers. So ... What is the best way to pass NSArray/NSMutableArray amongst several ViewControllers ... all of which can modify and/or set it to nil or whatever? Thanks 回答1: There are two approaches, generally speaking. In the first approach, when you instantiate your next view controller, you could set an array property to "inherit"

Help w/ array of dictionaries in a tableview

十年热恋 提交于 2019-12-25 04:29:14
问题 This is kinda confusing so please bear with me. I have an array (listOfStates) of dictionaries. Where listOfStates has this structure: {stateName} - {stateCapital} {Alabama} - {Montgomery} {Alaska} - {Juneau} {Arizona} - {Phoenix} ... {West Virginia} - {Charleston} {Wisconsin} - {Madison} {Wyoming} - {Cheyenne} This is the code used to obtain the 1st letter of each US State(stateName) in order to group them together alphabetically: listOfStates = [[NSArray alloc] init]; stateIndex = [

'String' is not identical to 'AnyObject' error

对着背影说爱祢 提交于 2019-12-25 03:07:43
问题 I'm having issues when trying to pass data to my Apple Watch app through NSUserDefaults from my app. Whenever I try to retrieve the array that is stored, I am getting the error 'String' is not identical to 'AnyObject' . I've been trying to figure out a solution but I can't work out what the issue is since I am using the same method elsewhere in my app and it works without issue. Here is what I have in the Apple Watch part: var defaults = NSUserDefaults(suiteName: "group.AffordIt") tempNames =

'String' is not identical to 'AnyObject' error

六眼飞鱼酱① 提交于 2019-12-25 03:07:05
问题 I'm having issues when trying to pass data to my Apple Watch app through NSUserDefaults from my app. Whenever I try to retrieve the array that is stored, I am getting the error 'String' is not identical to 'AnyObject' . I've been trying to figure out a solution but I can't work out what the issue is since I am using the same method elsewhere in my app and it works without issue. Here is what I have in the Apple Watch part: var defaults = NSUserDefaults(suiteName: "group.AffordIt") tempNames =

Why is this NULL?

…衆ロ難τιáo~ 提交于 2019-12-25 02:07:04
问题 Can anyone tell me why this is NULL ? So Array1 is NSMutable, and has an NSString object "UserName" at index 0; NSLog (@"Contents of array1 %@", [array1 objectAtIndex:0]); //prints UserName Now , I do this... array2 belongs to another class. I reference the class, import .h file, and add property and synthesize it. [object2.array2 addObject: array1]; //array2 is NSMutable properly initialized in it's respective class in the init method NSLog (@"Contents of array2 %@", [object2.array2

Using Three20's TTLauncherView: Need help with splitting and adding remaining objects from an NSMutableArray to an NSArray in Objective-C

不羁岁月 提交于 2019-12-25 01:52:38
问题 I am now using this code: - (void)loadLauncher:(NSMutableArray *)categoriesArray { _launcherView = [[TTLauncherView alloc] initWithFrame:self.view.bounds]; _launcherView.columnCount = 3; // Number of pages in your launcherView. NSMutableArray *pages = [[NSMutableArray alloc] initWithCapacity:2]; int numberOfObjects = [categoriesArray count]; // The launcherItems in each page, calculate automatically the number of objects available for the launcher. NSMutableArray *launcherItems = [