Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Well it all goes into a dictionary, it goes

Dictionary -> Array ->String

String being the last line of data.
So, what I'm suggesting instead is:

Dictionary -> Array -> Dictionary

where the last dictionary contains three key-value pairs for the address, city and time.

Can you please help me to get this thing working?
I thought I was helping. If there is something else in the way of help, specifically, that you are looking for, you should explain what it is.
 
Ok Ill give that a shot, if don't mind could you please look at the post i posted like 3 posts ago and look at the code and tell me if you see any reason why it isn't showing up on load?
 
...if don't mind could you please look at the post i posted like 3 posts ago and look at the code and tell me if you see any reason why it isn't showing up on load?
I did look at that post and I already questioned it in a follow-up post (from which you never answered my first question). As well, you have not really explained what StaticClass is or provided the code for it so it is very difficult for us to interpret how you expect to be using it.

If your plist really does contain Dictionary -> Array -> String, then I don't see how these lines even work because each key-value pair of the dictionary is an array, correct?:
Code:
NSString *value;
value = [plistDict objectForKey:@"key"];

It seems to me, and sorry if this sounds harsh, you don't have a good grasp of the fundamentals of tableView datasources. Normally, you set up some kind of data lookup structure outside the cellForRowAtIndexPath (usually in viewDidLoad) and then simply access that data source from within it. What have you read in terms of table view programming?
 
I have a good grasp of the UITableview just not of the data sources etc.

What do you need to know about the Static Class?


and you are correct, however i believe that

Code:
NSString *value;
value = [plistDict objectForKey:@"key"];

is getting that object and putting it into a string, I have confirmed this using NSLog


could you point me in the right direction then?
 
I have a good grasp of the UITableview just not of the data sources etc.
Since datasources (and delegation) are key parts of UITableView, then I would venture to say you don't really have a good grasp.

What do you need to know about the Static Class?
As much as possible. The interface and implementation files would probably be a good start.

however i believe that

Code:
NSString *value;
value = [plistDict objectForKey:@"key"];

is getting that object and putting it into a string, I have confirmed this using NSLog
Then your plist is not Dictionary -> Array but rather Dictionary -> String, at least for the @"key" object.

could you point me in the right direction then?
Maybe. I'm not sure what, specifically, you are looking for direction for.
 
Last edited:
This is the array that in the static class, So what happens is when the user selects done in the parking part of the app it gets written to those arrays, I wrote a method that writes from those arrays to the plist.

Code:
+ (void)set_logObjectsArray:(NSMutableArray *)newVar
{
    if (newVar == nil)
        _logObjectsArray = [[NSMutableArray alloc] init];
    else
        _logObjectsArray = [[NSMutableArray alloc] initWithArray:newVar]; 
}

+ (void)add_logObj:(NSString *)var
{
    [_logObjectsArray addObject:var];
}

+ (NSMutableArray *)get_logObjectsArray { return _logObjectsArray; }

Now when the user clicks the history tab, I want to write a method definition that fills the table with the data that has been written into plist. however from the code I have written, it doesn't display the information and I want to know how i can display that information.


I just PM'ed could you please check your inbox?

EDIT:

I just want to know the string that is currently holding that information from the plist, i want it to display in the textLabel and the detailText. But it won't display and gives me and error saying

"Void value not ignored as it ought to be"

Code:
cell.textLabel.text = [[self readPlist] objectAtIndex:indexPath.row];
 
Last edited by a moderator:
I just want to know the string that is currently holding that information from the plist, i want it to display in the textLabel and the detailText. But it won't display and gives me and error saying

"Void value not ignored as it ought to be"

Code:
cell.textLabel.text = [[self readPlist] objectAtIndex:indexPath.row];

Obvious question: What does [self readPlist] return?

You haven't posted code for it, so no one knows the answer except you.
 
Code:
- (void)readPlist
{
	NSString *filePath = @"/Users/rlakhani/Desktop/Parking Pro/ParkingPro 28/ParkingPro/Data.plist";
	NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
	NSString *his;
	his = [plistDict objectForKey:@"key"];
        [StaticClass add_logObj:his];
	NSLog(@"%@", his);
}

it doesn't return anything, however im adding the String to the array
 
Can you post the entire interface and implementation files for StaticClass, please? That code snippet does not provide enough context. For example, we can't know how _logObjectsArray is defined, although we can guess, but we shouldn't have to.

Also, it would probably help to post the code where "it gets written to those arrays".
 
//interface StaticClass

Code:
//
//  StaticClass.h
//  ParkingThing
//
//  Created by WeSaM on 5/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface StaticClass : NSObject {
    
}

+ (void)set_mapViewType:(int)var;
+ (int)get_mapViewType;

+ (void)set_directionMode:(int)var;
+ (int)get_directionMode;

+ (void)set_searchRadius:(int)var;
+ (int)get_searchRadius;


+ (void)set_isMapTagged:(BOOL)newVar;
+ (BOOL)get_isMapTagged;

+ (BOOL)get_isTimerSet;
+ (void)set_isTimerSet:(BOOL)newVar;

+ (void)set_pinLatitude:(double)newVar;
+ (double)get_pinLatitude;

+ (void)set_pinLongitude:(double)newVar;
+ (double)get_pinLongitude;

+ (void)set_note:(NSString *)newVar;
+ (NSString *)get_note;

+ (void)set_parkingTimeStamp:(NSDate *)var;
+ (NSDate *)get_parkingTimeStamp;

+ (void)set_parkingTimer:(double)newVar;
+ (double)get_parkingTimer;

+ (void)set_logObjectsArray:(NSMutableArray *)newVar;
+ (void)add_logObj:(NSString *)var;

+ (NSMutableArray *)get_logObjectsArray;

+ (void)set_xml3Arrays:(NSMutableArray *)newVar;
+ (NSMutableArray *)get_xml3Arrays;

+ (NSString *)extractAddress:(double)latitude :(double)longitude;

+ (NSArray *)splitAddress:(NSString *)inputAddress;

+ (NSString *)get_adKey;

@end

//implementation StaticClass

Code:
//
//  StaticClass.m
//  ParkingThing
//
//  Created by WeSaM on 5/16/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "StaticClass.h"


@implementation StaticClass

static int _mapViewType = 0;
static int _directionMode = 0;
static int _searchRadius = 1000;

static BOOL _isMapTagged = NO;
static BOOL _isTimerSet = NO;
static double _pinLatitude = 00.000000;
static double _pinLongitude = 00.000000;
static NSString *_note = @"";
static NSDate *_parkingTimeStamp = nil;
static double _parkingTimer = 0.0;

static NSMutableArray *_logObjectsArray = nil;
static NSMutableArray *_xml3Arrays = nil;
static NSString *_adKey = ;



+ (void)set_mapViewType:(int)var { _mapViewType = var; }
+ (int)get_mapViewType{ return _mapViewType; }

+ (void)set_directionMode:(int)var { _directionMode = var; }
+ (int)get_directionMode{ return _directionMode; }

+ (void)set_searchRadius:(int)var { _searchRadius = var; }
+ (int)get_searchRadius{ return _searchRadius; }


+ (void)set_isMapTagged:(BOOL)newVar { _isMapTagged = newVar; }
+ (BOOL)get_isMapTagged { return _isMapTagged; }

+ (BOOL)get_isTimerSet { return _isTimerSet; }
+ (void)set_isTimerSet:(BOOL)newVar { _isTimerSet = newVar; }

+ (void)set_pinLatitude:(double)newVar { _pinLatitude = newVar; }
+ (double)get_pinLatitude { return _pinLatitude; }

+ (void)set_pinLongitude:(double)newVar { _pinLongitude = newVar; }
+ (double)get_pinLongitude { return _pinLongitude; }

+ (void)set_note:(NSString *)newVar
{ 
    if (newVar == nil || [newVar length] == 0) 
        _note = @"";
    else
        _note = [[NSString alloc] initWithString:newVar]; 
}
+ (NSString *)get_note { return _note; }

+ (void)set_parkingTimeStamp:(NSDate *)var
{
    _parkingTimeStamp = var;
}
+ (NSDate *)get_parkingTimeStamp { return _parkingTimeStamp; }

+ (void)set_parkingTimer:(double)newVar { _parkingTimer = newVar; }
+ (double)get_parkingTimer { return _parkingTimer; }

+ (void)set_logObjectsArray:(NSMutableArray *)newVar
{
    if (newVar == nil)
        _logObjectsArray = [[NSMutableArray alloc] init];
    else
        _logObjectsArray = [[NSMutableArray alloc] initWithArray:newVar]; 
}

+ (void)add_logObj:(NSString *)var
{
    [_logObjectsArray addObject:var];
}

+ (NSMutableArray *)get_logObjectsArray { return _logObjectsArray; }


+ (void)set_xml3Arrays:(NSMutableArray *)newVar
{
    if (newVar == nil)
        _xml3Arrays = [[NSMutableArray alloc] initWithObjects:nil];
    else
        _xml3Arrays = [[NSMutableArray alloc] initWithArray:newVar]; 
}
+ (NSMutableArray *)get_xml3Arrays { return _xml3Arrays; }



+ (NSString *)extractAddress:(double)latitude :(double)longitude {
	NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",
                           [NSString stringWithFormat:@"%f,%f", latitude, longitude]];
	
	NSString *locationString = [[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
	
	locationString = [locationString substringToIndex:[locationString length] - 1];
	
	return [locationString substringFromIndex:7];
}


+ (NSArray *)splitAddress:(NSString *)inputAddress {
	return [inputAddress componentsSeparatedByString:@","];
}

+ (NSString *)get_adKey { return _adKey; }

@end
 
Code:
cell.textLabel.text = [[StaticClass get_logObjectsArray] objectAtIndex:indexPath.row];

i have changed it however when i print out the get_logObjectsArray and it prints null so im kinda lost as to what to do next
 
Code:
cell.textLabel.text = [[StaticClass get_logObjectsArray] objectAtIndex:indexPath.row];

i have changed it however when i print out the get_logObjectsArray and it prints null so im kinda lost as to what to do next
Apply some basic debugging. What do you expect to happen?: get_logObjectsArray is not-null. And what is actually happening?: get_logObjectsArray is null.

So, you need to figure out if _logObjectsArray is always nil. Where do you initialize it? Where do you add objects to it? Put breakpoints into these places and confirm that 1) they are being called, and 2) that _logObjectsArray is becoming non-nil and new objects are added at these points.
 
The _logObjectsArray gets initialized to nil in the static class. I'm not quite sure how to add the objects to the _logObjectsArray.
 
The _logObjectsArray gets initialized to nil in the static class.
Initializing and setting to nil are different things. If you want to add objects to an array, you need to init it first (which, I believe, you do in your set_logObjectsArray: method).

I'm not quite sure how to add the objects to the _logObjectsArray.
Well, if you're not sure how to add objects to an array, how can you expect it to contain any elements and, thus, not be nil? Are you sure you are comfortable enough with the fundamentals to feel you can properly code your desired app?
 
The _logObjectsArray gets initialized to nil in the static class. I'm not quite sure how to add the objects to the _logObjectsArray.

If you're going to add objects to _logObjectsArray, then the first thing you need is a non-nil _logObjectsArray. Since you need _logObjectsArray to be an NSMutableArray, which of the methods you posted creates an NSMutableArray and assigns it to _logObjectsArray? Is that method actually being called from somewhere? You wrote the code, so you should be able to look at it and follow the logic.

The second thing you need to do to add objects to the _logObjectsArray is to call the method that adds objects to the _logObjectsArray. Again, look at the code you wrote and follow the logic.

Something you should consider when adding objects to the _logObjectsArray is to check _logObjectsArray for nil, and either NSLog an error message, or abort() the program, or something like that. You can use C assert() or NSAssertion for this, if you understand what those are.

If you don't know how to use NSLog or the debugger for these simple debugging problems, then you should stop working on this program, go back to a simpler program that you've already written and run successfully, and learn how to apply these basic debugging skills. It's much easier to learn how to use the debugger on a program that works than on one that doesn't.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.