Pergunta

I need to convert my [self.fetchedResultsController fetchedObjects] to NSArray.

I've already tried before use [self.fetchedResultsController fetchedObjects] but it returns me a lot of properties from other Atributes that I don't need. I just want to get a list of values from a concrete attribute called circuito inside the entity Autobus.

Foi útil?

Solução

[self.fetchedResultsController fetchedObjects] will return array of instances of the entity specified by the fetch request. Here fetchedObjects return array of Autobus entities. To get array of values from a concrete attribute called circuito do

[[self.fetchedResultsController fetchedObjects] valueForKey:@"circuito"];

Outras dicas

First of all I would clarify about used terminology. The "lot of code" that you received is not correct.

As per the documentation for fetchedObjects property:

The results array only includes instances of the entity specified by the fetch request (fetchRequest) and that match its predicate.
(If the fetch request has no predicate, then the results array includes all instances of the entity specified by the fetch request)


In other words, you grab instances of your entity Autobus

So, in my opinion you should clarify

  1. What is the lot of code you grab
  2. Why you don't want the lot of code
  3. What's your goal

For example:
If you need to display results in a table view you will make visible the only attributes you are interested in.
You won't grab the ones that are not useful for a specific user interface.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top