There are no bugs in the code but my Dictionary doesnt get loaded
CODE:
//
// SectionsViewController.m
// Sections
//
// Created by Kunwar Handa on 25/05/11.
// Copyright 2011 Fortune4 Technologies. All rights reserved.
//
#import "SectionsViewController.h"
@implementation SectionsViewController
@synthesize names;
@synthesize keys;
#pragma mark -
#pragma mark UIViewController Methods
-(void)viewDidLoad{
NSString *path = [[NSBundle mainBundle] pathForResource:@"sortednames" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
self.names= dict;
[dict release];
NSArray *array = [[names allKeys] sortedArrayUsingSelector:@selector(compare:)];
self.keys= array;
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[names release];
[keys release];
[super dealloc];
}
#pragma mark -
#pragma mark Table View Data Source Methods
-(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];
NSUInteger row = [indexPath row];
NSString *key = [keys objectAtIndex:section];
NSArray *nameSection = [names objectForKey:key];
static NSString *SectionTableIdentifier = @"SectionTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SectionTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:SectionTableIdentifier] autorelease];
}
cell.text = [nameSection objectAtIndex:row];
return cell;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *key = [keys objectAtIndex:section];
return key;
}
@end
**LOG:**
Build Sections of project Sections with configuration Debug
ProcessInfoPlistFile /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/Info.plist Sections-Info.plist
cd /Users/kunwarhanda/Documents/Sections
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
builtin-infoPlistUtility Sections-Info.plist -genpkginfo /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/PkgInfo -expandbuildsettings -format binary -platform iphonesimulator -o /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/Info.plist
CompileXIB /Users/kunwarhanda/Documents/Sections/MainWindow.xib
cd /Users/kunwarhanda/Documents/Sections
setenv IBC_MINIMUM_COMPATIBILITY_VERSION 4.2
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/ibtool --errors --warnings --notices --output-format human-readable-text --compile /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/MainWindow.nib /Users/kunwarhanda/Documents/Sections/MainWindow.xib --sdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
CompileXIB /Users/kunwarhanda/Documents/Sections/SectionsViewController.xib
cd /Users/kunwarhanda/Documents/Sections
setenv IBC_MINIMUM_COMPATIBILITY_VERSION 4.2
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/ibtool --errors --warnings --notices --output-format human-readable-text --compile /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/SectionsViewController.nib /Users/kunwarhanda/Documents/Sections/SectionsViewController.xib --sdk /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk
ProcessPCH /var/folders/6o/6oRlqcHSG3i+gabLJ+MCV++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/Sections_Prefix-gyjbjzxosthibsbszggxsbxqehxr/Sections_Prefix.pch.gch Sections_Prefix.pch normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/kunwarhanda/Documents/Sections
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c-header -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-generated-files.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-own-target-headers.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-all-target-headers.hmap -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-project-headers.hmap -F/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -I/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/include -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources/i386 -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources -c /Users/kunwarhanda/Documents/Sections/Sections_Prefix.pch -o /var/folders/6o/6oRlqcHSG3i+gabLJ+MCV++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/Sections_Prefix-gyjbjzxosthibsbszggxsbxqehxr/Sections_Prefix.pch.gch
CompileC build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/main.o /Users/kunwarhanda/Documents/Sections/main.m normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/kunwarhanda/Documents/Sections
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-generated-files.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-own-target-headers.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-all-target-headers.hmap -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-project-headers.hmap -F/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -I/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/include -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources/i386 -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources -include /var/folders/6o/6oRlqcHSG3i+gabLJ+MCV++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/Sections_Prefix-gyjbjzxosthibsbszggxsbxqehxr/Sections_Prefix.pch -c /Users/kunwarhanda/Documents/Sections/main.m -o /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/main.o
CompileC build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/SectionsAppDelegate.o /Users/kunwarhanda/Documents/Sections/Classes/SectionsAppDelegate.m normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/kunwarhanda/Documents/Sections
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-generated-files.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-own-target-headers.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-all-target-headers.hmap -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-project-headers.hmap -F/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -I/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/include -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources/i386 -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources -include /var/folders/6o/6oRlqcHSG3i+gabLJ+MCV++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/Sections_Prefix-gyjbjzxosthibsbszggxsbxqehxr/Sections_Prefix.pch -c /Users/kunwarhanda/Documents/Sections/Classes/SectionsAppDelegate.m -o /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/SectionsAppDelegate.o
CompileC build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/SectionsViewController.o Classes/SectionsViewController.m normal i386 objective-c com.apple.compilers.gcc.4_2
cd /Users/kunwarhanda/Documents/Sections
setenv LANG en_US.US-ASCII
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fexceptions -fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200 -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-generated-files.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-own-target-headers.hmap -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-all-target-headers.hmap -iquote /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Sections-project-headers.hmap -F/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -I/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/include -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources/i386 -I/Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/DerivedSources -include /var/folders/6o/6oRlqcHSG3i+gabLJ+MCV++++TM/-Caches-/com.apple.Xcode.502/SharedPrecompiledHeaders/Sections_Prefix-gyjbjzxosthibsbszggxsbxqehxr/Sections_Prefix.pch -c /Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m -o /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/SectionsViewController.o
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m: In function '-[SectionsViewController viewDidLoad]':
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:27: warning: incompatible Objective-C types 'struct NSArray *', expected 'struct NSDictionary *' when passing argument 1 of 'setKeys:' from distinct Objective-C type
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m: In function '-[SectionsViewController tableView:numberOfRowsInSection:]':
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:99: warning: 'NSDictionary' may not respond to '-objectAtIndex:'
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:99: warning: (Messages without a matching method signature
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:99: warning: will be assumed to return 'id' and accept
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:99: warning: '...' as arguments.)
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m: In function '-[SectionsViewController tableView:cellForRowAtIndexPath:]':
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:110: warning: 'NSDictionary' may not respond to '-objectAtIndex:'
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:120: warning: 'setText:' is deprecated (declared at /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableViewCell.h:211)
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m: In function '-[SectionsViewController tableView:titleForHeaderInSection:]':
/Users/kunwarhanda/Documents/Sections/Classes/SectionsViewController.m:127: warning: 'NSDictionary' may not respond to '-objectAtIndex:'
Ld build/Debug-iphonesimulator/Sections.app/Sections normal i386
cd /Users/kunwarhanda/Documents/Sections
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -L/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -F/Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator -filelist /Users/kunwarhanda/Documents/Sections/build/Sections.build/Debug-iphonesimulator/Sections.build/Objects-normal/i386/Sections.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -o /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/Sections
GenerateDSYMFile build/Debug-iphonesimulator/Sections.app.dSYM build/Debug-iphonesimulator/Sections.app/Sections
cd /Users/kunwarhanda/Documents/Sections
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/usr/bin/dsymutil /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app/Sections -o /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app.dSYM
Touch build/Debug-iphonesimulator/Sections.app
cd /Users/kunwarhanda/Documents/Sections
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/usr/bin/touch -c /Users/kunwarhanda/Documents/Sections/build/Debug-iphonesimulator/Sections.app
it’s true – ‘NSDictionary’ does not respond to ‘-objectAtIndex:’
the compiler points out the source line of the problem, for example:
SectionsViewController.m:99
and xcode will probably highlight it for you too.