I am making a plist viewer and editor for iOS, but the problem I have it, that the values don't match to its key. Like I have this plist
{
BuildMachineOSBuild = 12C54;
CAProcessCanAccessGPU = 1;
CFBundleAllowMixedLocalizations = 1;
CFBundleDevelopmentRegion = English;
CFBundleDisplayName = iAd;
CFBundleExecutable = AdSheet;
CFBundleIconFiles = (
"iAd.png",
"iAd#2x.png"
);
CFBundleIcons = {
CFBundlePrimaryIcon = {
CFBundleIconFiles = (
"iAd.png",
"iAd#2x.png"
);
UIPrerenderedIcon = 0;
};
};
CFBundleIdentifier = "com.apple.AdSheetPhone";
CFBundleInfoDictionaryVersion = "6.0";
CFBundleName = AdSheet;
CFBundlePackageType = APPL;
CFBundleResourceSpecification = "ResourceRules.plist";
CFBundleShortVersionString = "1.0";
CFBundleSignature = "????";
CFBundleSupportedPlatforms = (
iPhoneOS
);
CFBundleVersion = "1.0";
CLSystemService = 1;
CLVisibleImmediately = 1;
CanInheritApplicationStateFromOtherProcesses = 1;
DTCompiler = "com.apple.compilers.llvm.clang.1_0";
DTPlatformBuild = "";
DTPlatformName = iphoneos;
DTPlatformVersion = "7.0";
DTSDKBuild = 11A450;
DTSDKName = "iphoneos7.0.internal";
DTXcode = 0500;
DTXcodeBuild = 5A1344i;
MinimumOSVersion = "7.0";
NSPrincipalClass = ADSApplication;
SBAppTags = (
hidden
);
SBMachServices = (
"com.apple.AdSheetPhone.server",
"com.apple.AdSheetPhone.management",
"com.apple.uikit.viewservice.com.apple.AdSheetPhone"
);
UIBackgroundModes = (
continuous
);
UIDeviceFamily = (
1,
2
);
UIShouldIgnoreRemoteControlEvents = 1;
UIStatusBarHidden = 1;
UISupportedInterfaceOrientations = (
UIInterfaceOrientationPortrait,
UIInterfaceOrientationPortraitUpsideDown,
UIInterfaceOrientationLandscapeLeft,
UIInterfaceOrientationLandscapeRight
);
UIViewServiceUsesNSXPCConnection = 1;
}
)
I try to display the value and its key (or Dictionary for Dictionaries, Array for Arrays and Bool for Bools)
Then for example CanInheritApplicationStateFromOtherProcesses should show a 1 (wich is a BOOL), but is don't show any value. And CanInheritApplicationStateFromOtherProcesses is on index 0 of my UITableView, but it is on index 19 of the plist. Does anyone know how to fix this error. I am displaying the key in the cell.textLabel.text and the value in cell.detailTextLabel.text. Here is my code of - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:#"plist Cell" forIndexPath:indexPath];
id obj;
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.detailTextLabel.minimumScaleFactor = 0.5;
cell.textLabel.font = [UIFont systemFontOfSize:14];
cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
cell.editingAccessoryType = UITableViewCellEditingStyleNone;
if (self.plistDict) {
NSString* key = [[self.plistDict allKeys] objectAtIndex:indexPath.row];
cell.textLabel.text = key;
obj = [self.plistDict objectForKey:key];
} else {
cell.textLabel.text = [NSString stringWithFormat:#"%li", (long)indexPath.row];
obj = [self.plistArray objectAtIndex:indexPath.row];
}
if(([obj isKindOfClass:[NSArray class]] || [obj isKindOfClass:[NSMutableArray class]]) && cell.tag == 0){
cell.detailTextLabel.text = NSLocalizedString(#"Array", nil);
cell.tag = 1;
return cell;
} if(([obj isKindOfClass:[NSDictionary class]] || [obj isKindOfClass:[NSMutableDictionary class]]) && cell.tag == 0){
cell.detailTextLabel.text = NSLocalizedString(#"Dictionary", nil);
cell.tag = 2;
return cell;
} if ([obj isKindOfClass:[NSString class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSString *)obj];
cell.tag = 3;
return cell;
} if ([obj isKindOfClass:[NSNumber class]]) {
if ([obj isKindOfClass:[#(YES) class]] && cell.tag == 0) {
[boolSwitch setOn:(BOOL)obj animated:YES];
[cell.contentView addSubview:boolSwitch];
cell.detailTextLabel.textColor = [UIColor clearColor];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.tag = 7;
return cell;
} else if (![obj isKindOfClass:[#(YES) class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSNumber *)obj];
cell.tag = 4;
return cell;
} else {
return cell;
}
} if ([obj isKindOfClass:[NSData class]] && cell.tag == 0) {
cell.detailTextLabel.text = NSLocalizedString(#"Data", nil);
cell.tag = 5;
return cell;
} if ([obj isKindOfClass:[NSDate class]] && cell.tag == 0) {
cell.detailTextLabel.text = [NSString stringWithFormat:#"%#", (NSDate *)obj];
cell.tag = 6;
return cell;
} else {
return cell;
}
The odd thing is for the most keys the value matches, but not for all.
cell will be reused with tag. so you maybe should reset the tag before reuse the cell:
//CustomeCell.m
- (void)prepareForReuse{
[super prepareForReuse];
self.tag = 0;
}
Or in tableView delegate class:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.tag = 0;
}
Related
I have a question here. In textDidChange function, i have NSMutableArray _setItem2 with "name","image","price" columns. And in this case, I able to search by "Name" column via sample code as below.
However, i would like to present my other columns value such as price and image after search filtering. How can i do that? Please help.
-(void)searchBar:(UISearchBar*)searchBar textDidChange:(NSString*)text
{
if(text.length == 0)
{
isFiltered = FALSE;
[searchBar resignFirstResponder];
}
else
{
isFiltered = true;
filteredTableData = [[NSMutableArray alloc] init];
for (NSDictionary *item in _setItem2) {
NSString *name = [item objectForKey:#"name"];
NSRange nameRange = [name rangeOfString:text options:NSCaseInsensitiveSearch];
if (nameRange.location != NSNotFound) {
[filteredTableData addObject:name];
}
}
}
[self.collectionView reloadData];
}
And here is my cellForItemAtIndexPath function
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
DCListGridCell *cell = nil;
cell = (_isSwitchGrid) ? [collectionView dequeueReusableCellWithReuseIdentifier:DCListGridCellID forIndexPath:indexPath] : [collectionView dequeueReusableCellWithReuseIdentifier:DCSwitchGridCellID forIndexPath:indexPath];
if(isFiltered)
{
NSString *str1 = [filteredTableData objectAtIndex:indexPath.row];
//HOW CAN I SHOW IMAGE AND PRICE HERE??? NOW THE VALUE IS WRONG
//==============================================================
//cell.productImage = [[_setItem2 objectAtIndex:indexPath.row] image];
cell.productName = [filteredTableData objectAtIndex:indexPath.row];
//cell.productPrice = [[_setItem2 objectAtIndex:indexPath.row] price];
}
else
{
cell.productImage = [_setItem[indexPath.row]valueForKey:#"image"];
cell.productName = [_setItem[indexPath.row]valueForKey:#"name"];
cell.productPrice = [_setItem[indexPath.row]valueForKey:#"price"];
}
return cell;
}
I know this is repeated question but i am not getting solution on my issue..I have designed UITableView programmatically but it's working fine till 4 sections or 9 rows but when I am trying to add any extra cell it's overriding first cell on last cell and vice versa.Please solve my issue.Thanks in advance.
my code is -
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 6;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 0)
return 1;
else if (section == 1)
return 1;
else if (section == 2)
return 3;
else if (section == 3)
return 2;
else if (section == 4)
return 2;
else if (section == 5)
return 3;
else
return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
if ((indexPath.section == 0) && (indexPath.row ==0)) {
cell.textLabel.text = #"";
//Get it from previous view
chooseEventLbl.text = #"Choose an event";
//chooseEventLbl.textColor = [UIColor darkGrayColor];
[cell addSubview:chooseEventLbl];
//cell.textLabel.text = #"Choose an event";
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 20)];
[image setImage:[UIImage imageNamed:#"arrow_list.png"]];
cell.accessoryView = [[UIImageView alloc]initWithFrame:CGRectMake(260.0, 7.0, 10, 20)];
[cell.accessoryView addSubview:image];
}
else if ((indexPath.section == 1) && (indexPath.row == 0))
{
cell.textLabel.text = #"";
[cell addSubview:squareNameTxt];
}
else if ((indexPath.section == 2) && (indexPath.row == 0))
{
cell.textLabel.text = #"Public";
}
else if ((indexPath.section == 2) && (indexPath.row == 1))
{
cell.textLabel.text = #"Private";
}
else if ((indexPath.row == 2) && (indexPath.row == 2) && (passwordFlag == TRUE))
{
cell.textLabel.text = #"";
[cell addSubview:passwordTxt];
// passwordTxt.enabled = NO;
}
else if ((indexPath.section == 3) && (indexPath.row == 0))
{
cell.textLabel.text = #"Allow multiple Squares";
[aSwitch addTarget:self action:#selector(switchChanged:) forControlEvents:UIControlEventValueChanged];
aSwitch.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:aSwitch];
}
else if ((indexPath.section == 3) && (indexPath.row == 1)) {
cell.textLabel.text = #"";
[cell addSubview:multiSquareListBtn];
}
else if ((indexPath.section == 4) && (indexPath.row == 0))
{
cell.textLabel.text = #"Prizes";
}
else if ((indexPath.section == 4) && (indexPath.row == 1))
{
cell.textLabel.text = #"";
[cell addSubview: firstQuarterTxt];
[cell addSubview:halftimeTxt];
[cell addSubview:thirdQuarterTxt];
[cell addSubview:finalTxt];
}
else if ((indexPath.section == 5) && (indexPath.row ==0))
{
cell.textLabel.text= #"";
currentLocationLbl.text = #"Choose Current Location";
[cell addSubview:currentLocationLbl];
}
else if ((indexPath.section == 5) && (indexPath.row == 1))
{
cell.textLabel.text = #"";
mapLocationLbl.text = #"Choose location from Map";
[cell addSubview:mapLocationLbl];
}
else if ((indexPath.section == 5) && (indexPath.row == 2))
{
cell.textLabel.text = #"";
radiusLocationLbl.text = #"Location Radius";
[cell addSubview:radiusLocationLbl];
}
return cell;
}
I'm currently trying to make the code of an app I'm developing a bit more efficient and easier to read. Basically what this does is retrieve an array from NSUserDefaults of player names, and fills in the 6 text boxes (tagged 6-11) with these names. If there isn't an existing array it'll use another set of names. Any ideas for simplifying this code would be appreciated.
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
NSMutableArray *names = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:#"nameArray"]];
for (int i = 0; i <= 5; i++) {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
UITableViewCell *cell = [playerTable cellForRowAtIndexPath:indexPath];
for (UIView *view in cell.contentView.subviews) {
if ([view isKindOfClass:[UITextField class]]) {
UITextField *txtField = (UITextField *)view;
if (txtField.tag == 6) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:0]; }
else {
txtField.text = #"Peter";
}
}
if (txtField.tag == 7) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:1]; }
else {
txtField.text = #"Julia";
}
}
if (txtField.tag == 8) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:2]; }
else {
txtField.text = #"Durgan";
}
}
if (txtField.tag == 9) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:3]; }
else {
txtField.text = #"Bob";
}
}
if (txtField.tag == 10) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:4]; }
else {
txtField.text = #"Iseland";
}
}
if (txtField.tag == 11) {
if([[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"]) {
txtField.text = [names objectAtIndex:5]; }
else {
txtField.text = #"Player";
}
}
}
}
}
[self saveNames];
}
Your could do this:
NSArray *defaultNames = #[#"Peter", #"Julia",...];
int offsetIndex = 6;
BOOl needCustomNames = [[NSUserDefaults standardUserDefaults] boolForKey:#"customNames"];
for (UIView *view in cell.contentView.subviews)
{
if ([view isKindOfClass:[UITextField class]])
{
UITextField *txtField = (UITextField *)view;
int index = [txtField tag]-offsetIndex;
if (tag >= 6 && tag <= 11)
{
if (needCustomNames)
textField.text = [names objectAtIndex:index];
else
textField.text = [defaultNames objectAtIndex:index];
}
}
}
For example, you called too many times the same lines in the for loop, like checking if you need to use or not a custom names (NSUserDefaults line).
I use an NSArray for the custom names to mimic the same logic, and used an offset to clarify it.
I would recommend to analyse your Code for redundance and exclude them in separate methods. so you have to call only the extern method than every code-party again and again.
I'm Having a custom cell which is consist of 3 different textfield txtsq,txtPOB,txtRxunit , and this custom cell m taking in my table view Controller, in table view Controller class inside the tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath , now i want to set the 3 different range limit of my 3 different text field which is in custom cell but i fail to set range in my
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string{
NSString *resultStr = [textField.text stringByReplacingCharactersInRange:range withString:string];
if (textField.tag ==SQ) {
if([self isNumeric:resultStr]){
if(resultStr.length <= 3){
if(resultStr.length >= 1){
NSString *firstLetter = [resultStr substringWithRange:NSMakeRange(0, 1)];
if(![firstLetter isEqualToString:#"0"]){
return YES;
}
}
else{
return YES;
}
}
}
}else
if([self isNumeric:resultStr]){
if(resultStr.length <= 5){
if(resultStr.length >= 1){
NSString *firstLetter = [resultStr substringWithRange:NSMakeRange(0, 1)];
if(![firstLetter isEqualToString:#"0"]){
return YES;
}
}
else{
return YES;
}
}
}
return NO;
}
I have already defined cell.txtSQ.tag=SQ;
cell.txtPOB.tag =POB;
cell.txtRxUnit.tag=RXunit;
After using this code my table view data is not persistent.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (self.skuNameArray.count > 0) {
OrderCell *cell = nil;
cell = (OrderCell *)[tableView dequeueReusableCellWithIdentifier:#"OrderCell"];
if(cell == nil){
cell = (OrderCell *)[OrderCell cellFromNibNamed:#"OrderCell"];
}
// Set Tag
cell.tag = indexPath.row;
cell.txtSQ.tag = indexPath.row;
cell.txtPOB.tag = indexPath.row;
cell.txtRxUnit.tag = indexPath.row;
// cell.txtSQ.tag=SQ;
//set Delegate
cell.txtPOB.delegate = self;
cell.txtRxUnit.delegate = self;
cell.txtSQ.delegate = self;
//set Values
cell.lblSKU.text = self.skuNameArray[indexPath.row];
cell.txtSQ.text = self.sqArray[indexPath.row];
cell.txtPOB.text = self.pobArray[indexPath.row];
cell.txtRxUnit.text = self.rxUnitArray[indexPath.row];
if (self.index == PCP || self.index == CURRENT_DAY_REPORTING_DETAIL) {
cell.txtSQ.enabled = NO;
cell.txtRxUnit.enabled = NO;
cell.txtPOB.enabled = NO;
}
[cell.txtSQ addTarget:self action:#selector(sqChanged:) forControlEvents: UIControlEventEditingChanged];
[cell.txtPOB addTarget:self action:#selector(pobChanged:) forControlEvents: UIControlEventEditingChanged];
[cell.txtRxUnit addTarget:self action:#selector(rxUnitChanged:) forControlEvents: UIControlEventEditingChanged];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
Your SQ may be dynamic . So, make it static.
or
you might not have set delegate to self. Do this :
cell.txtSQ.delegate = self;
cell.txtPOB.delegate = self;
cell.txtRxUnit.delegate = self;
Set your tag carefully :
// Set Tag
cell.txtSQ.tag = SQ;
cell.txtPOB.tag = POB;
cell.txtRxUnit.tag = RXunit;
I have two problems (in fact one - my code sucks):
My table takes a long time to load(about 5 seconds)
She is dreadfully poor
Any ideas?
My tableView methods:
// Table
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
RefreshDelegate *RefreshProtocol = [[RefreshDelegate new] autorelease];
RefreshProtocol.delegate = self;
return [[RefreshProtocol returnDataForTable] count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
RefreshDelegate *RefreshProtocol = [[RefreshDelegate new] autorelease];
RefreshProtocol.delegate = self;
NSArray *curent = [self curent:section];
return [curent count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
RefreshDelegate *RefreshProtocol = [[RefreshDelegate new] autorelease];
RefreshProtocol.delegate = self;
return [[[RefreshProtocol returnDataForTable] allKeys] objectAtIndex:section];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = #"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *curent = [self curent:indexPath.section];
cell.textLabel.text = [curent objectAtIndex:indexPath.row];
return cell;
}
- (NSArray*)curent:(NSInteger)index {
RefreshDelegate *RefreshProtocol = [[RefreshDelegate new] autorelease];
RefreshProtocol.delegate = self;
NSArray *keys = [[RefreshProtocol returnDataForTable] allKeys];
NSString *curentKey = [keys objectAtIndex:index];
NSArray *curent = [[RefreshProtocol returnDataForTable] objectForKey:curentKey];
return curent;
}
My RefreshProtocol methods:
#define MaxCountPair 7
-(NSDictionary *)returnDataForTable{
NSMutableArray *day_1 = [NSMutableArray arrayWithCapacity:MaxCountPair];
NSMutableArray *day_2 = [NSMutableArray arrayWithCapacity:MaxCountPair];
NSMutableArray *day_3 = [NSMutableArray arrayWithCapacity:MaxCountPair];
NSMutableArray *day_4 = [NSMutableArray arrayWithCapacity:MaxCountPair];
NSMutableArray *day_5 = [NSMutableArray arrayWithCapacity:MaxCountPair];
NSMutableArray *day_6 = [NSMutableArray arrayWithCapacity:MaxCountPair];
// Analysis db and write array today
NSArray *array = [SQLiteAccess selectManyRowsWithSQL:#"select * from schedule"];
for (int i = 0; i < [array count]; i++) {
NSDictionary *dictionary = [array objectAtIndex:i];
if ([self checkOverlapDigit:[[[NSUserDefaults standardUserDefaults] valueForKey:#"numberWeek"] objectForKey:#"numberWeek"]:[dictionary objectForKey:#"week"]] && [self checkOverlapDigit:[self subgroupToInt]:[dictionary objectForKey:#"subgroup"]]) {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue]]) {
[day_1 addObject:[dictionary objectForKey:#"subject"]];
}
else {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue] - 1]) {
[day_2 addObject:[dictionary objectForKey:#"subject"]];
}
else {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue] - 2]) {
[day_3 addObject:[dictionary objectForKey:#"subject"]];
}
else {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue] - 3]) {
[day_4 addObject:[dictionary objectForKey:#"subject"]];
}
else {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue] - 4]) {
[day_5 addObject:[dictionary objectForKey:#"subject"]];
}
else {
if ([self checkDay:[[dictionary objectForKey:#"day"] intValue] - 5]) {
[day_6 addObject:[dictionary objectForKey:#"subject"]];
}
}
}
}
}
}
}
}
NSDictionary *days = [NSDictionary dictionaryWithObjectsAndKeys:day_1, #"1", day_2, #"2", day_3, #"3", day_4, #"4", day_5, #"5", day_6, #"6", nil];
return days;
}
-(NSString *)removeAllButDigit:(NSString *)originalString{
// Remove all but digit
NSMutableString *strippedString = [NSMutableString
stringWithCapacity:originalString.length];
NSScanner *scanner = [NSScanner scannerWithString:originalString];
NSCharacterSet *numbers = [NSCharacterSet
characterSetWithCharactersInString:#"1234"];
while ([scanner isAtEnd] == NO) {
NSString *buffer;
if ([scanner scanCharactersFromSet:numbers intoString:&buffer]) {
[strippedString appendString:buffer];
} else {
[scanner setScanLocation:([scanner scanLocation] + 1)];
}
}
return strippedString;
}
-(BOOL)checkDay:(NSInteger)day{
NSString *currentDay = nil;
switch (day) {
case 1:
currentDay = NSLocalizedString(#"_monday", nil);
break;
case 2:
currentDay = NSLocalizedString(#"_tuesday", nil);
break;
case 3:
currentDay = NSLocalizedString(#"_wednesday", nil);
break;
case 4:
currentDay = NSLocalizedString(#"_thursday", nil);
break;
case 5:
currentDay = NSLocalizedString(#"_friday", nil);
break;
case 6:
currentDay = NSLocalizedString(#"_saturday", nil);
break;
default:
break;
}
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:#"EEEE"];
if ([currentDay isEqualToString:[dateFormatter stringFromDate:[NSDate date]]]) {
return YES;
}
return NO;
}
-(BOOL)checkOverlapDigit:(NSString *)smallerString:(NSString *)largerString{
if ([largerString isEqualToString:#"0"]) {
return YES;
}
NSInteger intSmaller = [[self removeAllButDigit:smallerString] intValue];
NSInteger intLarger = [[self removeAllButDigit:largerString] intValue];
while (1) {
if (intLarger % 10 != 0) {
NSInteger sedimentWeek = intLarger % 10;
if (sedimentWeek == intSmaller) {
return YES;
}
intLarger /= 10;
}
else {
if (intLarger / 10 != 0) {
intLarger /= 10;
if (intLarger == intSmaller) {
return YES;
}
}
else {
return NO;
}
}
}
}
-(NSString *)subgroupToInt{
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"subgroupValue"] isEqualToString: #"subgroupValue1"]) {
return #"1";
}
else
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"subgroupValue"] isEqualToString: #"subgroupValue2"]) {
return #"2";
}
else
if ([[[NSUserDefaults standardUserDefaults]objectForKey:#"subgroupValue"] isEqualToString: #"subgroupValue3"]) {
return #"3";
}
return #"4";
}
And SQLiteAccess class: .h, .m
For starting... you can (you have) to create you object only once!! (in the constructor? In -viewDidLoad ?)
Then in the tableView delegate methods you access your (unique) object.
EDIT:
Adds a property in your class:
#property (nonatomic, strong) RefreshDelegate* refreshProtocol;
In your -viewDidLoad method add
-(void)viewDidLoad
{
[super viewDidLoad];
self.refreshProtocol = [[RefreshDelegate new] autorelease];
self.refreshProtocol.delegate = self;
}
Now:
- (NSArray*)curent:(NSInteger)index {
NSArray *keys = [[self.refreshProtocol returnDataForTable] allKeys];
NSString *curentKey = [keys objectAtIndex:index];
NSArray *curent = [[self.refreshProtocol returnDataForTable] objectForKey:curentKey];
return curent;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *curent = [self curent:section];
return [curent count];
}
... and correct the other methods...