I'm new here at stackoverflow :) But I think, this is the right place to ask my question.
I'm a new developer with Cocoa and Objective-c & I'm trying to write my first App for Mac: a ToDo App.
At this moment, i can save ToDo's and delete them, but now, I want to add some features like CreationDate, some Tags (in mutablearray), and if the ToDo is finished or not. Im not working with an ArrayController, I'm saving the encoded NSMutableArray into a File (Library/Application Support/AppName) and reading it from there.
This all must be in one Row, because it is looking Like this:
Current appearance http://img683.imageshack.us/img683/7595/bild2ss.png
Where Title is, should be the Content of the ToDo, where the Blue Box is, should be the Status (Blue = undone, Grey = Done) and where Subtitle is should be the Date and the Tags (03.01.2009 - tag1, tag2, tag3)
I now how to addObjects into an mutablearray but, if i wanna save all this 4 informations into this array, i dont know how to make this.
I've got an Model, which is initializing with this 4 infomations, but how to save this? Must I save this for informations in one array and this array in my mutablearray?
The solution is actually the opposite: Have one object per row.
This is where your model layer (the M in MVC) comes in: The object for each row is a model object, an instance of a class you construct, and the icon, title, and subtitle are properties of that object.
Then, make a custom cell for your table column to display the model object in that way. The cell is part of the View layer—the V in MVC.
The C in MVC sits in between the Model and View: It's the object that owns the model and is the data source (whether by Bindings or not) of the table view. The table view gets the model objects from this object to feed them to the cell. This middle object is a Controller.
Now i have it!
I've only one Cell for the Content with an ArrayController.
I'm setting the other Informations with -(id)init for each row.
There are 3 Objects: content, status and date, and for each status i display another image (done, undone, ...).
Thank you very much for your Help! I'm trying to finish the Beta for everyone :)
Related
Forgive me, I'm not a proper JS programmer and still getting my head around a lot of concepts.
Suppose one had a group of similar, 2-frame/2-state rollover movie clips nested inside a containing clip, which has the instance name "Map". Each clip uses a 4 digit ID number preceded by an "s" as an instance name – e.g., "s6566".
Suppose one then wanted to capture those respective instance names to define a variable, such that one small script could allow each of these movie clips to display their ID on rollover/active state (in this case "6566"), across multiple files.
Ultimately I have thousands of these little clips spread across several dozen documents, and it seems it should be fairly simple to grab each symbol's instance name/ID, strip off the "s" from the beginning (there because instance names can't begin with a numeral), and apply said ID as dynamic text to it's respective symbol's rollover/active frame.
Is there a method of achieving this goal? I wish I had some example code to include here, but I'm not quite sure how to begin, other than to lay out the problem thusly. Haven't yet been able to find any info on capturing instance names, and I'm not sure whether it's possible. Thanks.
Children of MovieClips are stored as references using their instance name. You can see the format in the exported library JS file. Note that Animate will convert some instance names to remove unsupported characters or duplicates.
Here is some untested pseudo-code to get you started.
// You can iterate a MovieClip and get the names
for (var name in someMovieClip) {
// Ignore anything not starting with an s
if (name.substr(0,1) != "s") { continue; }
// remove the s
var newName = name.substr(1);
// The child can be accessed using bracket-access with its name
var child = someMovieClip[name];
// The child should have text instances if it is set up how you described
// Set the text to the newName
child.textInstance.text = newName
}
Don't forget to update the stage after you make changes. If you already have Ticker set up to do that, it should update immediately.
I hope that helps. If you have follow-up questions, let me know.
I can't get my head around my objective C code. I want to make a dictionary with persons that I save in the app. The dictionary is in first empty and then we need to add it from the textfields I created (see image)textfieldWelkom
For every person that is added, we have to show it in a list (see image) lijstTabblad in the tableviewcontroller. (The list has to be the whole name of the person)
I don't get the idea of how to making a dictionary with multiple persons with every person his own ELEMENTS. And how that I can get the elements again out of de dictionary for making the list etc..
(not like the 1 example but multiple values with that person)
I would be sow thankfull if you could help me!
Greetings,
Kevin
You needs to first create single person dictionary dictionary keys
are like name sirname age and put values for respected keys
add this dictionary in one array or another dictionary(array/dictionary must be mutable array)
I am wondering if its possible to have a core data and use a NSFetchedResultsController to display template holders; without saving the placeholder template holder to core data.
I am writing an app where a table view will have the following characteristics
Maximum amount of rows (ie: 8)
Each cell uses a partial view, a single table cell instance with clickable buttons;
A user clicking on the buttons replaces the content for each button
When a user comes to save the data it stores the content in the exact places, but crucially it should not save the blank placeholder state; but still respect the placement positioning.
IE: Lets say a user picks the right button for cell 1 and saves it;
when the the user returns to this dataset sometime in the future, it
should have the imagery and data in the correct place; but still keep
the left button for cell 1 empty (placeholder)
The reason I don't want to save the placeholder content is because I consider this data to be "dirty"; its meaningless and has no place in a dataset; its a view; not data.
Currently:
I create data using insertInManagedObjectContext but do not save it until the user has pressed save.
Each matchRow has many fighters. This relationship is a NSOrderedSet, managed by core data.
The problems I'm having are;
NSFetchedResultsController only respects saved core data items; and ignores the placeholder data.
If a user only saves one (right button) data, the NSOrderedSet sees this as the first (left button) data; which is in correct
If I strip out all the placeholder structures from the core data in a pre-save action, the effect is that the order the user wanted is now lost and it causes a crash when reloading because the size of the arrays are incorrect.
Currently the only way around this is to stop using
NSFetchedResultsController and use a NSArray; and put the placeholders into the array too, then save everything, (dirty objects) and all.
I really don't want to do that. The placeholder content isn't meant to be saved.
I've been reading a blog post on using separate classes for special cases where he has different data sources; and uses the technique to separate class for the "empty" case, and to set it as the table view’s datasource when it's empty.
Whilst this is interesting, it only solves it for an empty case; when my requirement is that the partial view should handle all states; empty data and partial data.
One idea I have is that we need another entity between our record and our match rows;
Match - MatchRowMeta - Fighter
Not sure what the relationship would be
where;
RowMeta {
record.obj (relationship)
fighters.obj (relationship)
positionID (integer) - which button has been set
}
But I don't think this is the best way to do it; it seems expensive and a lot of heavy lifting to do something relatively simple.
Thus, my question:
Is it possible to have a table view made up of template holders; where the structure is saved to core data but none of the empty (dirty) objects are saved; plus NSFetchedResultsController will respect the structure; even when its empty or partially empty?
Edit: Added entity diagram
I would like to make some bindings that toggle item titles in a popup menu based on a single numerical value in a text field. Let me explain:
This is my UI:
I want my menu items to automatically adjust to singular or plural based on the number in the text field. For example, when I type "1" in the box, I want the menu items to be labeled "minute", "hour" and "day". When I type "4", I want the menu items to be labeled "minutes", "hours" and "days".
What I did to date:
I bound the three menu item's labels to the same key path as the text field's value.
I created an NSValueTransformer subclass to interpret the value in the text field and return singular or plural to be used as item titles.
I applied this value transformer to the three bindings.
The issue:
My value transformer can either return singular or plural but it can't set the appropriate string based on the menu item it's applied to.
It looks to me like a value transformer is generic and can't return different values for different destinations. That would mean that to have the three titles change automatically, I would need to have three different value transformers that return the appropriate string for each menu item. That doesn't seem optimal at all.
Ideally I would be able to combine a string stored in the destination menu item (let's say in the item's tag property) with an "s" in the value transformer when the text field's value is larger than one, or something similar that would enable me to use a single value transformer for all the menu items.
Is there something I missed? What would be an ideal solution?
Okay, this is probably not an ideal solution, but something you could consider: if you set your value transformers from your code (and not in IB), you could instantiate 3 different transformers of the same class. You could give your value transformer an ivar NSString *unit (and add something like [[MyValueTransformer alloc] initWithUnit:]) to allow each to return their own string, but you still have to write the value transformer's code only once.
(Also, if you're ever going to consider making your application localizable, simply appending an "s" to create the plurals is not going to work. You could of course add ivars for both NSString *singular and NSString *plural to do that.)
Edit: Wait, I just realized you can register value transformers! If you register them as MyValueTransformerHours and MyValueTransformerMinutes (by manually allocating and initializing them in your code), you can use them from Interface Builder. See also https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ValueTransformers/Concepts/Registration.html#//apple_ref/doc/uid/20002166-BAJEAIEE.
I am using Core Data and want a Text Label to display how many rows there are in the table, what code would I need to enter in the class file's to do this?
Assuming your NSTableView's columns are bound to an NSArrayController, you can bind the value of the NSTextField label to your array controller's with controller key "arrangedObjects" and with a key path of #count. If you want to bind the text field to something like "x rows" where x is the number of rows, you would bind the "Display Pattern Value1" to the same (arrangedObjects.#count) and use "%{value1}# rows" as the Display Pattern.
Set up a fetch request on your managed object context like you normally would, and call countForFetchRequest:. Don't forget to subscribe to NSManagedObjectContextObjectsDidChangeNotification so you can update it when objects are added or removed!