我宣布了一个NSMutable数组并为其分配了一些值。NSMutableArray问题
.h
NSMutableArray *imageDetailsFromCategory;
@property (nonatomic, retain) NSMutableArray *imageDetailsFromCategory;
.m
@synthesise imageDetailsFromCategory
在viewDidLoad中
:
imageDetailsFromCategory = [[NSMutableArray alloc]init];
//assigning object to Array..working fine.showing two images.
imageDetailsFromCategory = [self getImageDetailsFromCategory:generatedString];
我有,现在解决的一个问题。我有一个问题,那就是我将这个数组传递给StaticCategoryWithMultiImagePopOver类。
StaticCategoryWithMultiImagePopOver *staticCategoryWithMultiImagePopOver = [[StaticCategoryWithMultiImagePopOver alloc] init];
[staticCategoryWithMultiImagePopOver setParentImageDetailsArray:imageDetailsFromCategory];
在StaticCategoryWithMultiImagePopOver.h
NSMutableArray *nsmResult;
@property (nonatomic,retain)NSMutableArray *nsmResult;
的.m
@synthesize nsmResult
-(void)setParentImageDetailsArray:(NSMutableArray *)imageDetailsFromCategoryFromParent{
nsmResult=[[NSMutableArray alloc] init];
nsmResult=[imageDetailsFromCategoryFromParent retain];
}
传递的数组保持与每个索引处一些字符串变量类对象。
所以我通过代码收到此:
- (UITableViewCell *)tableView:(UITableView *)tableView15 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView15 dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil) {
// cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
// }
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString *documentsDirectory = [paths objectAtIndex:0];
SymbolTalkEntry *symbolTalkEntry = [[SymbolTalkEntry alloc]init];
symbolTalkEntry =[nsmResult objectAtIndex:indexPath.row];
NSString *imageNme = symbolTalkEntry.fileName; // *this line*
上述行越来越错误。
阵列显示计数,但对象是出scope..cant的获取值...
任何一个可以告诉我,我怎么能访问它......可我知道是什么问题我...
的cellForRowAtIndexPath(其工作的罚款)
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView15 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView15 dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil) {
// cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
// }
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSFileManager *fileManager = [NSFileManager defaultManager];//create instance of NSFileManager
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); //create an array and store result of our search for the documents directory in it
NSString *documentsDirectory = [paths objectAtIndex:0];
SymbolTalkEntry *symbolTalkEntry = [[SymbolTalkEntry alloc]init];
symbolTalkEntry =[nsmResult objectAtIndex:indexPath.row];
NSString *imageNme = symbolTalkEntry.fileName;
[symbolTalkEntry release];
//Display image from app bundle
NSString *path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png",imageNme]];
cell.imageView.image= [UIImage imageWithContentsOfFile:path];
return cell;
}
-(NSInteger)number
是StaticCategoryWithMultiImagePopOver您的表视图数据源吗?或者'cellForRowAtIndexPath'方法中的文件是什么? – jtbandes
为什么你总是'alloc init'如果你打算指向另一个对象之后呢? –
@jtbandes:是的...... – Christina