How can i save NSArray of MPMediaPlaylist to NSUserDefaults - nsarray

I try to save my NSArray of MPMediaPlaylist
[[NSUserDefaults standardUserDefaults] setObject:self.playlistArray forKey:#"playlist"];
[[NSUserDefaults standardUserDefaults] synchronize];
But i have error
-[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '(
"<MPConcreteMediaPlaylist: 0x1e8614a0>"
)' of class '__NSArrayM'. Note that dictionaries and arrays in property lists must also contain only property values.
2013-06-26 20:06:44.393 Fitness[5326:907] (
"<MPConcreteMediaPlaylist: 0x1e8614a0>"
)
So how can i resolve this problems?
Thanks you guy

Because self.playlistArray is NSMutableArray.So you got this error. Have a look at following links.
Saving a NSMutableArray using NSUserDefaults not working
NSUserDefaults NSMutable Array Not Saving Between Sessions
insert object in an NSMutableArray saved with NSUserDefaults

Related

Add a new colomn from value that is stored in a list of cell of the table

I'm quite new to powerbi developement, and I need your help.
I have a table build from a json :
And I want to add informations to this table, using data from the column "fille".
This cells are fill with 'List'
This 'List' are 'Record' :
And inside this record, I can find my information :
The field that I need is :
For each row of main table
set the value "avancement" of the first 'Record' of the 'List'
How can I reach to do that ?
I'm trying somthing like this, without succes :
tableDev = Table.AddColumn(tableInfoFiltree, "Dev", each tableInfoFiltree[filles]{_}{0}[nom], type text)
I try also to build a function, but, the same, I don't reach to extract the List from the cell to put it in parameter.
Thanks for the help
Try this.
= Table.AddColumn(tableInfoFiltree, "Custom", each [filles]{0}[avancement])

Filling a DataGridView ComboBox with values in C/C++

I'm creating a windows forms application for university. My data is stored in multible c arrays of abstract data types. Each array is displayed in it's own datagridview. This all works no problem.
Since the data is connected like in a database I added a new column to my parent table and set the ColumnType to DataGridViewComboBoxColumn. Now I need to fill this combobox with the data of a different array / datagridview.
I've already tried to add the options manually from my array as discribed in this question: Filling DataGridView ComboBox programatically in unbound mode?. Since I need to use C/C++ and this example uses vb the used functions are not availible. I can select my column dataGridView1->Columns[0] but the ->Items does not exist.
Is it possible to create a datasource from my arrays to link them directly? Or have I overlooked a way to add them manually from my array?
You don't provide any code, neither you describe well where did you ran into a problem. Assuming you're after unbound list to be filled into the DataGridViewComboBoxColumn, here is a simple example.
C#:
DataTable dt;
dt.Columns.Add("ID", typeof(Int32));
dt.Columns.Add("Category", typeof(string));
dt.Rows.Add({1, "Fruits"});
dt.Rows.Add({2, "Vegetables"});
dt.Rows.Add({3, "Trees"});
DataGridViewComboBoxColumn dgCol = this.DataGridView1.columns("Category");
dgCol.ValueMember = "ID";
dgCol.DisplayMember = "Category";
dgCol.DataSource = dt;
In this example, we create a DataTable, fill it with desired values and use it as a DataSource of the DataGridViewComboBoxColumn. Obviously, your values provided to this column in the DataGridView DataSource must match IDs in the list in new DataTable "dt".
You can convert an array or other data into DataTable or even use them directly as DataSource. It depends on what data you have. The principle will be very similar, though.
VB.NET:
Dim dt As DataTable
dt.Columns.Add("ID", GetType(Int32))
dt.Columns.Add("Category", GetType(String))
dt.Rows.Add({1, "Fruits"})
dt.Rows.Add({2, "Vegetables"})
dt.Rows.Add({3, "Trees"})
Dim dgCol As DataGridViewComboBoxColumn = Me.DataGridView1.columns("Category")
dgCol.ValueMember = "ID"
dgCol.DisplayMember = "Category"
dgCol.DataSource = dt

QSqlRelationalDelegate in QSqlRelationalTableModel shows foreign key instead of its value

Here is my code:
QSqlRelationalTableModel *model = new QSqlRelationalTableModel(this, db1);
model->setTable("syllabi");
model->setRelation(3, QSqlRelation("activity_types", "activity_type_id", "activity_type_name"));
model->select();
ui->tableView->setModel(model);
ui->tableView->setItemDelegate(new QSqlRelationalDelegate(ui->tableView));
Values in combo boxes show correctly, but when I change the value and select another cell of the table, the cell shows the ID (foreign key) instead of its value.
Also, when I insert another value with this code
model->insertRow(model->rowCount());
model->setData(model->index(model->rowCount()-1, 0), teacherName);
there is a error:
QODBCResult::exec: Unable to execute statement: "[Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting the nvarchar value 'default' to data type int."
The tables did't join correctly?
EDIT:
Okay, now when I change value in combo box it deletes the whole row. What might be the reason?
The tables: https://yadi.sk/i/ujL15zD_hupvz
I know it's pretty late, but anyway, here is the answer.
I have encountered the same problem but in pyqt. The problem was with EditStrategy.OnFieldChange That should behave like OnRowChange when inserting a new row but somehow keeps skipping lookups for relations during the edit of the new row. Changing the EditStrategy to OnRowChange solves the problem.
Here is the original answer I got for my problem.

Get the values of columns of Doctrine 2 entity - not objects, just values

Let's say I have an entity called Game which has a home_school_id. I can of course do $myGame->getHomeSchool()->getId() if I want that school's id, but that takes up too much memory. How can I just directly get home_school_id?
In your GameRepository.php. Then, do a $game->getHomeSchoolId($id);
You'll just have to work with your select, from and where, but that's really easy.
public function getHomeSchoolId($id)
{
return $this
->_em
->createQueryBuilder()
->select('q.home_school_id')
->from('BundleMyBundle:HomeSchool', 'q')
->where('q.something = :id')
->setParameter('id', $id)
->getQuery()
->getResult();
}
If you want the ID of another entity, which is linked through a relation, you'll have to do a join. Just ask if you need more informations.

Is creating a custom model the way to access data in a table by name?

Say I have a QTableWidget with 10 columns. I set data in the table with
QTableWidgetItem* textItem1 = new QTableWidgetItem;
textItem1->setData(Qt::DisplayRole, 20);
this->tableWidget->setItem(row, col, textItem1);
The problem is that if I change the order or titles of the columns in the table using QtDesigner, I have to go through my code and change all of the column numbers. I would rather do something like this:
QTableWidgetItem* textItem1 = new QTableWidgetItem;
textItem1->setData(Qt::DisplayRole, "Smith");
this->tableWidget->setLastName(row, textItem1);
to add "Smith" to the "LastName" column, without needing to know which column index LastName currently is. Is the way to do this with a custom Model? I looked into QAbstractTableModel, but I don't understand how to provide named access to data? Can anyone briefly explain how one would do this? And if this is a reasonable/common thing to want to do?
Thanks.
I posted an example of using QAbstractTableModel:
http://programmingexamples.net/index.php?title=Qt/ModelView/QAbstractTableModel
As you can see, the data is simply stored in a member variable, and can therefore be accessed however you would like.