0
私はルーム属性(NSString)のnsetsを持っています。私はそれらをCoreDataに保存しました。 UILabelに表示するにはどうすればいいですか?CoreDataからNSSetを取り出してラベルに表示します
私はのviewDidLoadでこれを試してみました:
NSArray *array = [[currentRaum raumattribute] allObjects];
[roomAttributLabel setText:[NSString stringWithFormat:@"%@",array]];
が、それはうまくいきませんでした。 currentRaumの
Raum *raum2 = [NSEntityDescription insertNewObjectForEntityForName:@"Raum" inManagedObjectContext:context];
raum2.raumName = @"Main";
raum2.ort = @"Aschaffenburg";
raum2.strasse = @"Bruchtannenstr. 11";
raum2.etage = @"2. Stock, Raum 1.203";
raum2.beschreibung = @"Gut beleuchtet";
UIImage *img2 = [UIImage imageNamed:@"Main.jpg"];
NSData *data2 = UIImagePNGRepresentation(img2);
raum2.foto = data2;
NSSet *attributeFurRaum2 = [NSSet setWithObjects:attribute4,attribute5,attribute6,nil];
raum2.raumattribute= attributeFurRaum2;
宣言::
:self.currentRaum = [self.fetchedResultsController objectAtIndexPath:indexPath];
私はこのように保存されている3種類のNSStringsを期待これは私が私のコンテンツを保存する方法ですScreenshot
いくつかのコアデータコードを示します
Raumattribute *attribute4 =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
attribute4.attributname = @"Copyboard";
Raumattribute *attribute5 =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
attribute5.attributname = @"Flipchart";
Raumattribute *attribute6 =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
attribute6.attributname = @"Internetmöglichkeit";
あなたの速い返信をありがとうが、私はまだ奇妙なcoredata出力があります。ここではスクリーンショットです:http://i42.tinypic.com/eks5uc.jpg –
OK、私はあなたのコードよりもあなたの質問を見てもっと多くの時間を費やしました。あなたはNSString *の配列を持っていますが、実際にはコアデータエンティティの配列を持っています。 currentRaumの宣言と[currentRaum raumAttribute]が返すと予想されるものを表示すると、これはずっと簡単になります。 – DRVic
ああ申し訳ありませんが私のポストを更新しました –