Search Results

Search found 600 results on 24 pages for 'plist'.

Page 11/24 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Problem with writeToFile with array of NSDictionary objects

    - by Ken
    I'm trying to write an array of NSDictionary objects to a .plist file on the iPhone (OS 3.0). (They are actually NSCFDictionary objects when I call the [object class] method). My problem is that it won't write to file. If I set the array to "nil" it at least creates the empty plist file but won't do it if I have these objects in the array. My array is a parsed response from a JSON HTTP request and looks like this: { "title" = "A Movie"; "time_length" = "3:22"; }, { "title" = "Another Movie"; "time_length" = "1:40"; }, { "title" = "A Third Movie"; "time_length" = "2:10"; } The code to create the file is: [array writeToFile:[self dataFilePath] atomically:YES]; - (NSString *)dataFilePath { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory stringByAppendingPathComponent:@"data.plist"]; } Could the NCSFDictionary class of the objects in my array be preventing me from writing to file? Thanks for your help.

    Read the article

  • EXC_BAD_ACCESS with NSUserdefaults on iphone.

    - by Andreas Johannessen
    I have the following code in my ApplicationDelegate. My deployment target is 3.0 and upwards, however I get a EXC_BAD_ACCESS when I launch the app with the following code on my iPhone with 3.1.3, however on the simulator which has 4.2 it runs fine. I would really appriciate help on this one, thanks in advance. When I comment this block when I deploy to 3.1.3 device it runs without bad access. + (void)initialize { NSString *path = [[NSBundle mainBundle] bundlePath]; NSString *pListPath = [path stringByAppendingPathComponent:@"Settings.bundle/Root.plist"]; NSDictionary *pList = [NSDictionary dictionaryWithContentsOfFile:pListPath]; NSMutableArray *prefsArray = [pList objectForKey:@"PreferenceSpecifiers"]; NSMutableDictionary *regDictionary = [NSMutableDictionary dictionary]; for (NSDictionary *dict in prefsArray) { NSString *key = [dict objectForKey:@"Key"]; if(key) { id value = [dict objectForKey:@"DefaultValue"]; [regDictionary setObject:value forKey:key]; } } [[NSUserDefaults standardUserDefaults] registerDefaults:regDictionary]; } UPDATE: I traced the error to happen on this line: [[NSUserDefaults standardUserDefaults] registerDefaults:regDictionary]; So there is probaly another syntax on earlier iOS, or am I wrong?

    Read the article

  • why does entity framework+mysql provider enumeration returns partial results with no exceptions

    - by Freddy Rios
    I'm trying to make sense of a situation I have using entity framework on .net 3.5 sp1 + MySQL 6.1.2.0 as the provider. It involves the following code: Response.Write("Products: " + plist.Count() + "<br />"); var total = 0; foreach (var p in plist) { //... some actions total++; //... other actions } Response.Write("Total Products Checked: " + total + "<br />"); Basically the total products is varying on each run, and it isn't matching the full total in plist. Its varies widely, from ~ 1/5th to half. There isn't any control flow code inside the foreach i.e. no break, continue, try/catch, conditions around total++, anything that could affect the count. As confirmation, there are other totals captured inside the loop related to the actions, and those match the lower and higher total runs. I don't find any reason to the above, other than something in entity framework or the mysql provider that causes it to end the foreach when retrieving an item. The body of the foreach can have some good variation in time, as the actions involve file & network access, my best shot at the time is that when the .net code takes beyond certain threshold there is some type of timeout in the underlying framework/provider and instead of causing an exception it is silently reporting no more items for enumeration. Can anyone give some light in the above scenario and/or confirm if the entity framework/mysql provider has the above behavior? Update: I can't reproduce the behavior by using Thread.Sleep in a simple foreach in a test project, not sure where else to look for this weird behavior :(.

    Read the article

  • does entity framework or mysql provider swallows timeout exceptions on enumeration of result?!

    - by Freddy Rios
    I'm trying to make sense of a situation I have using entity framework on .net 3.5 sp1 + MySQL 6.1.2.0 as the provider. It involves the following code: Response.Write("Products: " + plist.Count() + "<br />"); var total = 0; foreach (var p in plist) { //... some actions total++; //... other actions } Response.Write("Total Products Checked: " + total + "<br />"); Basically the total products is varying on each run, and it isn't matching the full total in plist. Its varies widely, from ~ 1/5th to half. There isn't any control flow code inside the foreach i.e. no break, continue, try/catch, conditions around total++, anything that could affect the count. As confirmation, there are other totals captured inside the loop related to the actions, and those match the lower and higher total runs. I don't find any reason to the above, other than something in entity framework or the mysql provider that causes it to end the foreach when retrieving an item. The body of the foreach can have some good variation in time, as the actions involve file & network access, my best shot at the time is that when it takes beyond certain threshold there is some type of timeout in the underlying framework/provider and instead of causing an exception it is silently reporting no more items for enumeration. Can anyone give some light in the above scenario and/or confirm if the entity framework/mysql provider has the above behavior?

    Read the article

  • Model class for NSDictionary information with Lazy Loading

    - by samfu_1
    My application utilizes approx. 50+ .plists that are used as NSDictionaries. Several of my view controllers need access to the properties of the dictionaries, so instead of writing duplicate code to retrieve the .plist, convert the values to a dictionary, etc, each time I need the info, I thought a model class to hold the data and supply information would be appropriate. The application isn't very large, but it does handle a good deal of data. I'm not as skilled in writing model classes that conform to the MVC paradigm, and I'm looking for some strategies for this implementation that also supports lazy loading.. This model class should serve to supply data to any view controller that needs it and perform operations on the data (such as adding entries to dictionaries) when requested by the controller functions currently planned: returning the count on any dictionary adding one or more dictionaries together Currently, I have this method for supporting the count lookup for any dictionary. Would this be an example of lazy loading? -(NSInteger)countForDictionary: (NSString *)nameOfDictionary { NSBundle *bundle = [NSBundle mainBundle]; NSString *plistPath = [bundle pathForResource: nameOfDictionary ofType: @"plist"]; //load plist into dictionary NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] initWithContentsOfFile: plistPath]; NSInteger count = [dictionary count] [dictionary release]; [return count] }

    Read the article

  • Should TcpClient be used for this scenario?

    - by Martín Marconcini
    I have to communicate with an iPhone. I have its IP Address and the port (obtained via Bonjour). I need to send a header that is “0x50544833” (or similar, It’s an HEX number), then the size of the data (below) and then the data itself. The data is just a string that looks like this: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE plist SYSTEM "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>clientName</key> <string>XXX</string> <key>clientService</key> <string>0be397e7-21f4-4d3c-89d0-cdf179a7e14d</string> <key>registerCode</key> <string>0000</string> </dict> </plist> The requirement also says that I must send the data in little endian format (which I think is the default for Intel anyway). So it would be: hex_number + size of data + string_with_the_above_xml. I need to send that to the iPhone and read the response. What would be, according to your experience, the best way to send this data (and read the response)?

    Read the article

  • Re-usable Obj-C classes with custom values: The right way

    - by Prairiedogg
    I'm trying to reuse a group of Obj-C clases between iPhone applications. The values that differ from app to app have been isolated and I'm trying to figure out the best way to apply these custom values to the classes on an app-to-app basis. Should I hold them in code? // I might have 10 customizable values for each class, that's a long signature! CarController *controller = [[CarController alloc] initWithFontName:@"Vroom" engine:@"Diesel" color:@"Red" number:11]; Should I store them in a big settings.plist? // Wasteful! I sometimes only use 2-3 of 50 settings! AllMyAppSettings *settings = [[AllMyAppSettings alloc] initFromDisk:@"settings.plist"]; MyCustomController *controller = [[MyCustomController alloc] initWithSettings:settings]; [settings release]; Should I have little, optional n_settings.plists for each class? // Sometimes I customize CarControllerSettings *carSettings = [[CarControllerSettings alloc] initFromDisk:@"car_settings.plist"]; CarController *controller = [[CarController alloc] initWithSettings:carSettings]; [carSettings release]; // Sometimes I don't, and CarController falls back to internally stored, reasonable defaults. CarController *controller = [[CarController alloc] initWithSettings:nil]; Or is there an OO solution that I'm not thinking of at all that would be better?

    Read the article

  • Deleting from 2 arrays of dictionaries

    - by Matt Winters
    I have an array of dictionaries loaded from a plist (below) called arrayHistory. <plist version="1.0"> <array> <dict> <key>item</key> <string>1</string> <key>result</key> <string>8.1</string> <key>date</key> <date>2009-12-15T19:36:59Z</date> </dict> ... </array> </plist> I filter this array based on 'item' so that a second array, arrayHistoryDetail has the same structure as arrayHistory but only contains e.g. 'item's equal to '1'. These detail items are successfully displayed in a tableView. I then want to select an item from the tableView, and delete it from the tableView data source, arrayHistoryDetail (line 2 in the code below) - works, then I want to delete the item from the tableView itself (line 3 in the code below) - also works. My problem is that I also need to delete it from the original arrayHistory, so I tried the following: created a temporary dictionary as an ivar: NSMutableDictionary *tempDict; @property (nonatomic, retain) NSMutableDictionary *tempDict; Then my thinking was to make a copy in line 1 and remove it from the original array in line 4. 1 tempDict = [arrayHistoryDetail objectAtIndex: indexPath.row]; 2 [arrayHistoryDetail removeObjectAtIndex: indexPath.row]; 3 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; 4 [arrayHistory removeObject:tempDict]; Didn't work. Could someone please guide me in the right direction. I'm thinking that tempDict is a pointer and that removeObject needs a copy? I don't know. Thanks.

    Read the article

  • How can I programmatically get the connection status of OSX network services?

    - by BigBrainz
    In the OS X System Preferences, when I click on 'Network' I see a green dot by 'Ethernet', and red dots by 'AirPort' and 'FireWire'. This is because I turned off AirPort and FireWire, as I access networks and the Internet via Ethernet. I need to programmatically determine which of these network services displayed in System Preferences have green dots and which have red dots. For Ethernet and FireWire the displayed status is 'Connected' or 'Not Connected', and for AirPort the displayed status is 'On' or 'Off'. Perhaps other network services have other status labels. I have picked through all the plist files in '/Library/Preferences/SystemConfiguration', particularly 'preferences.plist' and 'NetworkInterfaces.plist'. I can get all sorts of information there, such as the Location set, network service order, proxy information (which is also important to my task), but I cannot find how to determine whether a given network service is on or off--the equivalent of having the green dot displayed. I have also tried using System Configuration framework, specifically the SCNetworkConnectionGetStatus function, but all I get are invalid connection statuses. Does anyone know how to actually retrieve this connection status information? Thanks.

    Read the article

  • How do you enable syslogd to accept incoming connections on Snow Leopard from remote loggers?

    - by Emmel
    How do I get syslogd to accept incoming connections from remote hosts on Snow Leopard? I'd like to centralize logging such that various devices and systems send logs to Snow Leopard's syslogd, which normally hangs out on UDP 514. However, I'm unable to get them to successfully be accepted by good ole syslogd. I tcpdumped on the Snow Leopard box to verify that packets are being spouted to port 514 -- they are. I checked that syslogd is listening on 514 -- it's not. Googling around told me that, on older versions of OSX (don't you love the way things change so rapidly on OSX), one just had to add a flag to the syslogd daemon to allow remote; one did this in com.apple.syslogd.plist. However the syslogd daemon has no flags (at least in its man page) that suggests any remote anything. What's the solution to this? Secondary, less import but relevant question: What's 'newsyslog'? I see a plist file but it's not running (apparently). Thanks

    Read the article

  • Mac - Run java program at launch

    - by emd
    I want to launch a java program (server program) at computer start up. I can run it from the command line perfectly. I created /Library/Server/startFS.sh. The file is executable by root and contains: cd /Library/Server/FiloSync /usr/bin/java -jar /Library/Server/FiloSync/filosync-server-latest.jar -p 7000 -s 7001 I can't get my launchd plist included here, the formatting is all off. I can run it fine from the command line: './startFS.sh' but when I put create the plist (via Lingon), nothing happens. Now, when run, it outputs a few lines to the console. Might that be problem?? I have tried prepending 'nohup' and post pending '&', but no combination seems to work. Help please.

    Read the article

  • iOS 5: Enable Android Style Auto Correction Feature With A Simple Trick

    - by Gopinath
    Apple generally don’t let its users to play with their devices, but seems to be these days there are few things slipping through the nets. Smart users are able find some hacks and enable new features on iOS devices! Few days ago we heard about the hidden panorama feature built into iOS 5 and it could be enabled on a jail broken device. Here come another hidden feature unearthed by a smart geek in iOS 5 : enable Android style auto-correction on on-screen keyboard. Luckily to enable this feature you don’t need to jailbreak, all you need to do is to take backup of your device, edit a file and restore it back. Boom!  That’s it. To enable auto corrections feature on the on-screen keyboard of iOS 5 follow these steps Download iBackupBot and install it on your machine. It’s works on both Windows and Mac OS X. Backup your iPhone, iPod, or iPad with iTunes – plug in your iOS device and sync it. Open iBackupBot, locate your most recent backup and click on it Scroll down to Library/Preferences/com.apple.keyboard.plist and double-click on it.   Replace everything between the two <dict> with the following <key>KeyboardAutocorrectionLists</key> <string>YES</string> Save the plist file, then hit the "Restore From Backup" button in iBackupbot. Reboot your device to see the auto correction feature in action on your device’s on-screen keyboard. via lifehacker This article titled,iOS 5: Enable Android Style Auto Correction Feature With A Simple Trick, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • How do you enable syslogd to accept incoming connections on Snow Leopard from remote loggers?

    - by Emmel
    How do I get syslogd to accept incoming connections from remote hosts on Snow Leopard? I'd like to centralize logging such that various devices and systems send logs to Snow Leopard's syslogd, which normally hangs out on UDP 514. However, I'm unable to get them to successfully be accepted by good ole syslogd. I tcpdumped on the Snow Leopard box to verify that packets are being spouted to port 514 -- they are. I checked that syslogd is listening on 514 -- it's not. Googling around told me that, on older versions of OSX (don't you love the way things change so rapidly on OSX), one just had to add a flag to the syslogd daemon to allow remote; one did this in com.apple.syslogd.plist. However the syslogd daemon has no flags (at least in its man page) that suggests any remote anything. What's the solution to this? Secondary, less import but relevant question: What's 'newsyslog'? I see a plist file but it's not running (apparently). Thanks

    Read the article

  • Creating a newspaper that effects the game's economy?

    - by zardon
    I am writing a game in Objective C/cocos2d where a newspaper is a central part of what controls or rather effects the game's world economy as well as what a city might do (such as increase X, reduce Y) The newspaper is a bit like a "Chance card" in Monopoly, it has an effect on something. My question is, what is the best way to do write a newspaper that has both a random and specific effect within the game. Would the best strategy be to write out all the things a newspaper can affect, a PLIST of headlines (with placeholders). I think Tiny Tower uses a PLIST of events and it randomly picks an event, but I'm not sure how it actually parses it because certain events do different things. But then how do I parse all the scenarios that a newspaper can deliver? A big switch statement seems very long and complicated to do. I am wondering if there is a simpler way to handle this kind of thing. Related to this is that there might be no news that day and I'm not sure what the newspaper should display, should it just display the last headline? So, in summary. 1) A newspaper generates a headline, it affects different things, such as the world economy, prices, how city reacts 2) I need the newspaper to generate headlines (although there may be days when there are no headlines at all), but I am not sure how to parse it without using a big-ass switch statement. Thanks in advance.

    Read the article

  • How does one check whether the OS X "disabled" flag for launchd services is set?

    - by Charles Duffy
    According to the man page for launchctl (emphasis mine):    -w   Overrides the Disabled key and sets it to false. In previous versions, this option would modify the configuration file. Now the state of the Disabled key is stored elsewhere on-disk. Because the current state of the disabled flag is no longer set in the .plist file itself, checking for the Disabled key is no longer an accurate way to tell if the service will run on next boot. Where is this "elsewhere on-disk"? More to the point (and more importantly), how does one check whether this flag is set? Also, is it possible to set a service to run on next boot without forcing it to start immediately (as with launchctl load -w /Library/LaunchDaemons/my-service.plist)?

    Read the article

  • How to decrypt an encrypted Apple iTunes iPhone backup?

    - by afit
    I've been asked by a number of unfortunate iPhone users to help them restore data from their iTunes backups. This is easy when they are unencrypted, but not when they are encrypted, whether or not the password is known. As such, I'm trying to figure out the encryption scheme used on mddata and mdinfo files when encrypted. I have no problems reading these files otherwise, and have built some robust C# libraries for doing so. (If you're able to help, I don't care which language you use. It's the principle I'm after here!) The Apple "iPhone OS Enterprise Deployment Guide" states that "Device backups can be stored in encrypted format by selecting the Encrypt iPhone Backup option in the device summary pane of iTunes. Files are encrypted using AES128 with a 256-bit key. The key is stored securely in the iPhone keychain." That's a pretty good clue, and there's some good info here on Stackoverflow on iPhone AES/Rijndael interoperability suggesting a keysize of 128 and CBC mode may be used. Aside from any other obfuscation, a key and initialisation vector (IV)/salt are required. One might assume that the key is a manipulation of the "backup password" that users are prompted to enter by iTunes and passed to "AppleMobileBackup.exe", padded in a fashion dictated by CBC. However, given the reference to the iPhone keychain, I wonder whether the "backup password" might not be used as a password on an X509 certificate or symmetric private key, and that the certificate or private key itself might be used as the key. (AES and the iTunes encrypt/decrypt process is symmetric.) The IV is another matter, and it could be a few things. Perhaps it's one of the keys hard-coded into iTunes, or into the devices themselves. Although Apple's comment above suggests the key is present on the device's keychain, I think this isn't that important. One can restore an encrypted backup to a different device, which suggests all information relevant to the decryption is present in the backup and iTunes configuration, and that anything solely on the device is irrelevant and replacable in this context. So where might be the key be? I've listed paths below from a Windows machine but it's much of a muchness whichever OS we use. The "\appdata\Roaming\Apple Computer\iTunes\itunesprefs.xml" contains a PList with a "Keychain" dict entry in it. The "\programdata\apple\Lockdown\09037027da8f4bdefdea97d706703ca034c88bab.plist" contains a PList with "DeviceCertificate", "HostCertificate", and "RootCertificate", all of which appear to be valid X509 certs. The same file also appears to contain asymmetric keys "RootPrivateKey" and "HostPrivateKey" (my reading suggests these might be PKCS #7-enveloped). Also, within each backup there are "AuthSignature" and "AuthData" values in the Manifest.plist file, although these appear to be rotated as each file gets incrementally backed up, suggested they're not that useful as a key, unless something really quite involved is being done. There's a lot of misleading stuff out there suggesting getting data from encrypted backups is easy. It's not, and to my knowledge it hasn't been done. Bypassing or disabling the backup encryption is another matter entirely, and is not what I'm looking to do. This isn't about hacking apart the iPhone or anything like that. All I'm after here is a means to extract data (photos, contacts, etc.) from encrypted iTunes backups as I can unencrypted ones. I've tried all sorts of permutations with the information I've put down above but got nowhere. I'd appreciate any thoughts or techniques I might have missed.

    Read the article

  • CFBundleVersion error even though new version is higher

    - by Rob
    When trying to upload an upgrade binary to iTunes Connect, I am getting this error message even though I have updated CFBundleVersion in my info.plist file to a higher value (and checked the package contents after building it to be sure it copied over). I have already successfully submitted a different app upgrade by doing this same method, but for whatever reason it won't work this time. Any insights or is this an iTunes bug? The binary you uploaded was invalid. The key CFBundleVersion in the Info.plist file must contain a higher version than that of the previously uploaded version.

    Read the article

  • release does not free up memory in low-memory condidtion

    - by user322945
    I am trying to follow the Apple's recommendation to handle low-memory warnings (found in Session 416 of WWDC 2009 videos) by freeing up resources used by freeing up my dataController object (referenced in my app delegate) that contains a large number of strings for read from a plist: - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { [_dataController release]; _dataController = nil; NSLog([NSString stringWithFormat:@"applicationDidReceiveMemoryWarning bottom... retain count:%i", [_dataController retainCount]]); } But when I run ObjectAlloc within Instruments and simulate a Low-Memory Condition, I don't see a decrease in the memory used by my app even though I see the NSLog statements written out and the retain count is zero for the object. I do pass references to the app delegate around to some of the view controllers. But the code above releases the reference to the _dataController object (containing the plist data) so I would expect the memory to be freed. Any help would be appreciated.

    Read the article

  • executable was signed with invalid entitlements ?

    - by balraj
    HI,all I am trying to install an app in the iphone using the adhoc build configuration for this i have made all the things first i created the app id that is enable fort he APNS and then create the profile and certificates and than i download to my system and then in the project i have made a plist name Adhoc_Entitlements.plist and in the code signing entitlements i put it name with extension and in the bundle identifier i put the name of the identifier that is used in the provision file and when i try to install in the device it throws the error i have mentioned,Any solution or anything that i am doing wrong.This is the error message i got when i try to install in the device. Thanks the error message is as -- The entitlements specified in your application's code signing entitlements file do not match those specified in your provisioning profile.

    Read the article

  • Dashcode: How to create a custom/new Project Template?

    - by JJBigThoughts
    I'm trying to customize the javascript that Dashcode uses. So that I won't step on Apple's Project Templates, I want to make a custom project template that would appear as a choice after you click "New Project." I have been able to modify one of the existing templates (like, Custom, Browser, Utility, RSS, and Podcast). I can not, however, seem to add a new template to the list, like adding "JJ's Awesome New Cross Platform Template" as a choice. I have tried copying the directory Plugins/TemplateWebCustom.wdgtTemplate and changing in Custom's Info.plist file the com.apple.Dashcode.template.web.custom to, say com.apple.Dashcode.template.web.custom2 and in Resouces/project.plist updating the key value pair: TemplateIdentifier ==>com.apple.Dashcode.template.web.custom Is it possible to add a new Project Template? What the minimum steps? Thanks, JJ

    Read the article

  • Capturing a NSParseErrorException

    - by Martin
    Could someone tell me how I can capture a NSParseErrorException? The Situation: my app downloads a small .plist file. I convert this into dictionary using the string method -propertylist. This normally works fine. I check for a connection before going to retrieve the file, so it works fine if I've got a connection to the internet, and works fine when I don't. However, I discovered a use case that crashes. If I'm at location that requires authetication before connecting to the internet (at Starbucks, say) what's being returned by the app isn't a plist and the attempt to parse it causes the application to crash. So is there a way to transform my code so that the NSParseErrorException is caught and rather than crashing the program I can just skip over this piece of code? NSDictionary *temp = [myDownloadString propertyList]; I tried doing this if ([myDownloadString propertyList]==NSParseErrorException){ //do something } but that didn't work.

    Read the article

  • iPhone app throwing EXC_BAD_ACCESS with dictionary from contents of file

    - by Mark Szymanski
    I have the code NSArray *paths = [[NSArray alloc] initWithArray:NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)]; NSString *docsDirectory = [[NSString alloc] initWithString:[paths objectAtIndex:0]]; NSLog(@"This app's documents directory: %@",docsDirectory); NSString *docsDirectoryWithPlist = [[NSString alloc] initWithFormat:@"%@/Stuff.plist", docsDirectory]; BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:docsDirectoryWithPlist isDirectory:NO]; if (fileExists) { chdir([docsDirectory UTF8String]); NSMutableDictionary *readDict = [[NSMutableDictionary alloc] initWithContentsOfFile:@"Stuff.plist"]; in an application's applicationDidFinishLaunching method and whenever it gets to the last line it crashes, throwing EXC_BAD_ACCESS along the way. Thanks in advance!

    Read the article

  • iphone Odd Problem when using a custom cell

    - by Brodie4598
    Please note where I have the NSLOG. All it is displaying in the log is the first three items in the nameSection. After some testing, I discovered it is displaying how many keys there are because if I add a key to the plist, it will log a fourth item in log. nameSection should be an array of the strings that make up the key array in the plist file. the plist file has 3 dictionaries, each with several arrays of strings. The code picks the dictionary I am working with correctly, then should use the array names as sections in the table and the strings en each array as what to display in each cell. so if the dictionary i am working with has 3 arrays, NSLOG will display 3 strings from the first array: 2010-05-01 17:03:26.957 Checklists[63926:207] string0 2010-05-01 17:03:26.960 Checklists[63926:207] string1 2010-05-01 17:03:26.962 Checklists[63926:207] string2 then stop with: 2010-05-01 17:03:26.963 Checklists[63926:207] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSCFArray objectAtIndex:]: index (3) beyond bounds (3)' if i added an array to the dictionary, it log 4 items instead of 3. I hope this explanation makes sense... -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [keys count]; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger) section { NSString *key = [keys objectAtIndex:section]; NSArray *nameSection = [names objectForKey:key]; return [nameSection count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger section = [indexPath section]; NSString *key = [keys objectAtIndex: section]; NSArray *nameSection = [names objectForKey:key]; static NSString *SectionsTableIdentifier = @"SectionsTableIdentifier"; static NSString *ChecklistCellIdentifier = @"ChecklistCellIdentifier "; ChecklistCell *cell = (ChecklistCell *)[tableView dequeueReusableCellWithIdentifier: SectionsTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"ChecklistCell" owner:self options:nil]; for (id oneObject in nib) if ([oneObject isKindOfClass:[ChecklistCell class]]) cell = (ChecklistCell *)oneObject; } NSUInteger row = [indexPath row]; NSDictionary *rowData = [self.keys objectAtIndex:row]; NSString *tempString = [[NSString alloc]initWithFormat:@"%@",[nameSection objectAtIndex:row]]; NSLog(@"%@",tempString); cell.colorLabel.text = [tempArray objectAtIndex:0]; cell.nameLabel.text = [tempArray objectAtIndex:1]; return cell; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; if (cell.accessoryType == UITableViewCellAccessoryNone) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } else if (cell.accessoryType == UITableViewCellAccessoryCheckmark) { cell.accessoryType = UITableViewCellAccessoryNone; } [tableView deselectRowAtIndexPath:indexPath animated:NO]; } -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ NSString *key = [keys objectAtIndex:section]; return key; }

    Read the article

  • Function Object in Java .

    - by Tony
    I wanna implement a javascript like method in java , is this possible ? Say , I have a Person class : public class Person { private String name ; private int age ; // constructor ,accessors are omitted } And a list with Person objects: Person p1 = new Person("Jenny",20); Person p2 = new Person("Kate",22); List<Person> pList = Arrays.asList(new Person[] {p1,p2}); I wanna implement a method like this: modList(pList,new Operation (Person p) { incrementAge(Person p) { p.setAge(p.getAge() + 1)}; }); modList receives two params , one is a list , the other is the "Function object", it loops the list ,and apply this function to every element in the list. In functional programming language,this is easy , I don't know how java do this? Maybe could be done through dynamic proxy, does that have a performance trade off?

    Read the article

  • Is NSDictionary key order guaranteed the same as initialized if it never changes?

    - by Thaurin
    I've run into the same problem as found in this question. However, I have a follow-up question. I seem to be in the same situation as the original asker: I have a plist with a hierarchy of dictionaries that define a configuration screen. These are not mutable and will stay the same throughout the application. Since the original discussion seems to focus on problems arising from mutating the dictionary, I must ask for comfirmation: is the order of a dictionary guaranteed the same as they are in the plist, i.e. as it is read (with initWithContentsOfFile)? Can I use allKeys on it in this case to get a correct-order array of keys if the dictionary never changes?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >