English 中文(简体)
存在Array的问题
原标题:Having problems with Array

这里的社保会是我的主角。 我有一个叫做“无线电台”的物体,我在那里有几条插座,如电话、报称频率和称为“调频信息”的NSMutable Array。 在我看来控制器上,我获得一个包含像这样阵列的QLet数据库。

广播。 h

@interface radiostations : NSObject {

    NSString *format;
    NSString *city;
}

@property (nonatomic, retain) NSString *format;
@property (nonatomic, retain) NSString *city;

主计长。

radiostations *amStationClass = [[radiostations alloc] init];
NSMutableArray* amStationInfo = [[NSMutableArray alloc] init];

while (sqlite3_step(statement) == SQLITE_ROW)
    {
    NSString *cityField = [[NSString alloc] initWithUTF8String:
                                   (const char *) sqlite3_column_text(statement, 10)];
    NSString *formatField = [[NSString alloc] initWithUTF8String:
                                    (const char *) sqlite3_column_text(statement, 0)];
    [amStationInfo addObject:amStationClass];
                    [amStationClass setCity:cityField];
                    [amStationClass setFormat:formatField];
    }
[tabView reloadData];
sqlite3_finalize(statement);

接着,我提出了可上诉的意见。

NSString *cityValue = [(radiostations *)[amStationInfo objectAtIndex:indexPath.row] city];
NSString *formatValue = [(radiostations *)[amStationInfo objectAtIndex:indexPath.row] format];
cityLabel.text = cityValue;
formatLabel.text = formatValue;

起初,我处理几个阿雷拉,这只是罚款。 我随后作了改动,以便我只处理一个使用一组物体的阵列,现在它不工作。 我知道Kingk的问话,而没有做什么事情,那不会有任何问题。 看来,这些阵列并没有有人居住。

最佳回答

你们正在改变同样的<代码>射线/代码>物体的特性,并再次在阵列中添加。 您需要创建新的<代码>无线电台。 a. 每一行从贵格利特数据库下载的物体,并添加:

while (...) {
    // fetch data as before

    radiostations *record = [[radiostations alloc] init];
    [record setCity: cityField];
    [record setFormat: formatField];
    [amStationInfo addObject: record];
    [record release];
}

If you are using ARC you need to remove the line [record release];, otherwise it is necessary to avoid leaking those objects.

问题回答

where did you allocate/init your mutablearray? something like:

NSMutableArray* amStationInfo = [[NSMutableArray alloc] init];

您需要一劳永逸地分配,然后添加其中的物体。





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签