Derived Values in Core Data

Using Core Data - I have created a named NSManagedObject that has both a start time and end time.
I'd like to display a list of these Session and I'd like the SECTION headers to break per day, based on a Session's start date. So, I'm storing a time - and I need to group by a date.
Would I simply add a readonly property 'startDate' to the literal Session code (.h,.m) that Core Data generated from my data model - in which I would derive the start date from the start time? or would this be a case for declaring a 'transient' property in my Core Data model? I don't exactly know when to use or not to use Transient properties.
It would be used as follows:
fetchedResultsController_ =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:managedObjectContext_
sectionNameKeyPath:@"startDate"
cacheName:cacheName];
Will this manually defined property actually work in this method?
-Luther

Dear Abir,
Thanks a lot for your exact reply.
In tracking tab of UWL what you see is NOT the description given for workflow, it is the Work Item Text for that workflow.
This is absoltely correct. I inserted the container variables in workitem text from PFTC as you suggested. It worked like a Magic!!!
KR,
Bharath

Similar Messages

  • Bookmark to a section with a derived value

    WEBI Report:
    I have a section that is based on a derived value (=MonthNumberOfYear([Closed Date])) called [Month of Period].
    I want to Bookmark that section, but when I view the Map screen, "#FORMAT" is displayed for each record.  Clicking on any of them does access the appropriate record, but there is no way of telling what that is by the "#FORMAT" label.
    Any suggestions?
    Edited by: jandon on Aug 6, 2010 10:12 PM

    i dont see any problem with that
    you just create a new variable Month of Period
    =MonthNumberOfYear([Closed Date])
    and section based on this variable
    Regards
    Amr

  • Core Data, how default value is set @ XCode 4

    Hi,
    I updated XCode to 4.
    Then, in core data modeling mode, I cannot set default value.
    I couldn't find "default value" column. (only "Attribute" and "Type")
    Where has it gone?
    Message was edited by: Rascal3
    Message was edited by: Rascal3
    Message was edited by: Rascal3

    In the upper right corner there is a set of buttons with the label "View" and three buttons, the one on the right has a tooltip, "Hide or show the Utilities", and this is a quick way to slide the panel you are looking at in and out. I can't figure out if I can include a picture.

  • IPhone core data - fetched managed objects not being autoreleased on device (fine on simulator)

    I'm currently struggling with a core data issue with my app that defies (my) logic. I'm sure I'm doing something wrong but can't see what. I am doing a basic executeFetchRequest on my core data entity, but the array of managed objects returned never seems to be released ONLY when I run it on the iPhone, under the simulator it works exactly as expected. This is despite using an NSAutoreleasePool to ensure the memory footprint is minimised. I have also checked with Instruments and there are no leaks, just ever increasing allocations of memory (by '[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) allocWithEntity:]'). In my actual app this eventually leads to a didReceiveMemoryWarning call. I have produced a minimal program that reproduces the problem below. I have tried various things such as faulting all the objects before draining the pool, but with no joy. If I provide an NSError pointer to the fetch no error is returned. There are no background threads running.
    +(natural_t) get_free_memory {
        mach_port_t host_port;
        mach_msg_type_number_t host_size;
        vm_size_t pagesize;
        host_port = mach_host_self();
        host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
        host_page_size(host_port, &pagesize);
        vm_statistics_data_t vm_stat;
        if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
            NSLog(@"Failed to fetch vm statistics");
            return 0;
        /* Stats in bytes */
        natural_t mem_free = vm_stat.free_count * pagesize;
        return mem_free;
    - (void)viewDidLoad
        [super viewDidLoad];
        // Set up the edit and add buttons.
        self.navigationItem.leftBarButtonItem = self.editButtonItem;
        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(insertNewObject)];
        self.navigationItem.rightBarButtonItem = addButton;
        [addButton release];
        // Obtain the Managed Object Context
        NSManagedObjectContext *context = [(id)[[UIApplication sharedApplication] delegate] managedObjectContext];
        // Check the free memory before we start
        NSLog(@"INITIAL FREEMEM: %d", [RootViewController get_free_memory]);
        // Loop around a few times
        for(int i=0; i<20; i++) {
            // Create an autorelease pool just for this loop
            NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
            // Check the free memory each time around the loop
            NSLog(@"FREEMEM: %d", [RootViewController get_free_memory]);
            // Create a minimal request
            NSEntityDescription *entityDescription = [NSEntityDescription                                                 
                                                  entityForName:@"TestEntity" inManagedObjectContext:context];
            // 'request' released after fetch to minimise use of autorelease pool       
            NSFetchRequest *request = [[NSFetchRequest alloc] init];
            [request setEntity:entityDescription];
            // Perform the fetch
            NSArray *array = [context executeFetchRequest:request error:nil];       
            [request release];
            // Drain the pool - should release the fetched managed objects?
            [looppool drain];
        // Check the free menory at the end
        NSLog(@"FINAL FREEMEM: %d", [RootViewController get_free_memory]);
    When I run the above on the simulator I get the following output (which looks reasonable to me):
    2011-06-06 09:50:28.123 renniksoft[937:207] INITIAL FREEMEM: 14782464
    2011-06-06 09:50:28.128 renniksoft[937:207] FREEMEM: 14807040
    2011-06-06 09:50:28.135 renniksoft[937:207] FREEMEM: 14831616
    2011-06-06 09:50:28.139 renniksoft[937:207] FREEMEM: 14852096
    2011-06-06 09:50:28.142 renniksoft[937:207] FREEMEM: 14872576
    2011-06-06 09:50:28.146 renniksoft[937:207] FREEMEM: 14897152
    2011-06-06 09:50:28.149 renniksoft[937:207] FREEMEM: 14917632
    2011-06-06 09:50:28.153 renniksoft[937:207] FREEMEM: 14938112
    2011-06-06 09:50:28.158 renniksoft[937:207] FREEMEM: 14962688
    2011-06-06 09:50:28.161 renniksoft[937:207] FREEMEM: 14983168
    2011-06-06 09:50:28.165 renniksoft[937:207] FREEMEM: 14741504
    2011-06-06 09:50:28.168 renniksoft[937:207] FREEMEM: 14770176
    2011-06-06 09:50:28.174 renniksoft[937:207] FREEMEM: 14790656
    2011-06-06 09:50:28.177 renniksoft[937:207] FREEMEM: 14811136
    2011-06-06 09:50:28.182 renniksoft[937:207] FREEMEM: 14831616
    2011-06-06 09:50:28.186 renniksoft[937:207] FREEMEM: 14589952
    2011-06-06 09:50:28.189 renniksoft[937:207] FREEMEM: 14610432
    2011-06-06 09:50:28.192 renniksoft[937:207] FREEMEM: 14630912
    2011-06-06 09:50:28.194 renniksoft[937:207] FREEMEM: 14651392
    2011-06-06 09:50:28.197 renniksoft[937:207] FREEMEM: 14671872
    2011-06-06 09:50:28.200 renniksoft[937:207] FREEMEM: 14692352
    2011-06-06 09:50:28.203 renniksoft[937:207] FINAL FREEMEM: 14716928
    However, when I run it on an actual iPhone 4 (4.3.3) I get the following result:
    2011-06-06 09:55:54.341 renniksoft[4727:707] INITIAL FREEMEM: 267927552
    2011-06-06 09:55:54.348 renniksoft[4727:707] FREEMEM: 267952128
    2011-06-06 09:55:54.702 renniksoft[4727:707] FREEMEM: 265818112
    2011-06-06 09:55:55.214 renniksoft[4727:707] FREEMEM: 265355264
    2011-06-06 09:55:55.714 renniksoft[4727:707] FREEMEM: 264892416
    2011-06-06 09:55:56.215 renniksoft[4727:707] FREEMEM: 264441856
    2011-06-06 09:55:56.713 renniksoft[4727:707] FREEMEM: 263979008
    2011-06-06 09:55:57.226 renniksoft[4727:707] FREEMEM: 264089600
    2011-06-06 09:55:57.721 renniksoft[4727:707] FREEMEM: 263630848
    2011-06-06 09:55:58.226 renniksoft[4727:707] FREEMEM: 263168000
    2011-06-06 09:55:58.726 renniksoft[4727:707] FREEMEM: 262705152
    2011-06-06 09:55:59.242 renniksoft[4727:707] FREEMEM: 262852608
    2011-06-06 09:55:59.737 renniksoft[4727:707] FREEMEM: 262389760
    2011-06-06 09:56:00.243 renniksoft[4727:707] FREEMEM: 261931008
    2011-06-06 09:56:00.751 renniksoft[4727:707] FREEMEM: 261992448
    2011-06-06 09:56:01.280 renniksoft[4727:707] FREEMEM: 261574656
    2011-06-06 09:56:01.774 renniksoft[4727:707] FREEMEM: 261148672
    2011-06-06 09:56:02.290 renniksoft[4727:707] FREEMEM: 260755456
    2011-06-06 09:56:02.820 renniksoft[4727:707] FREEMEM: 260837376
    2011-06-06 09:56:03.334 renniksoft[4727:707] FREEMEM: 260395008
    2011-06-06 09:56:03.825 renniksoft[4727:707] FREEMEM: 259932160
    2011-06-06 09:56:04.346 renniksoft[4727:707] FINAL FREEMEM: 259555328
    The amount of free memory reduces each time round the loop in proportion to the managed objects I fetch e.g. if I fetch twice as many objects then the free memory reduces twice as quickly - so I'm pretty confident it is the managed objects that are not being released. Note that the entities that are being fetched are very basic, just two attributes, a string and a 16 bit integer. There are 1000 of them being fetched in the examples above. The code I used to generate them is as follows:
    // Create test entities
    for(int i=0; i<1000; i++) {
        id entity = [NSEntityDescription insertNewObjectForEntityForName:@"TestEntity" inManagedObjectContext:context];
        [entity setValue:[NSString stringWithFormat:@"%d",i] forKey:@"name"];
        [entity setValue:[NSNumber numberWithInt:i] forKey:@"value"];
    if (![context save:nil]) {
        NSLog(@"Couldn't save");
    If anyone can explain to me what is going on I'd be very grateful! This issue is the only only one holding up the release of my app. It works beautifully on the simulator!!
    Please let me know if there's any more info I can supply.

    Update: I modified the above code so that the fetch (and looppool etc.) take place when a timer fires. This means that the fetches aren't blocked in viewDidLoad.
    The result of this is that the issue happens exactly as before, but the applicationDidReceiveMemoryWarning is fired as expected:
    2011-06-08 09:54:21.024 renniksoft[5993:707] FREEMEM: 6131712
    2011-06-08 09:54:22.922 renniksoft[5993:707] Received memory warning. Level=2
    2011-06-08 09:54:22.926 renniksoft[5993:707] applicationDidReceiveMemoryWarning
    2011-06-08 09:54:22.929 renniksoft[5993:707] FREEMEM: 5615616
    2011-06-08 09:54:22.932 renniksoft[5993:707] didReceiveMemoryWarning
    2011-06-08 09:54:22.935 renniksoft[5993:707] FREEMEM: 5656576

  • Call Function in CL_RSPLS_CR_EXIT_BASE to derive values

    Dear all,
    we want to derive the location from item (material). If item gebinns with "EMU" then location is 2. If item beginns with "X" then locations is "68" and so on.
    To realise we chose characteristic relationship with derivation and based on "Exit Class".
    we copied the Class "CL_RSPLS_CR_EXIT_BASE" to "Z_CL_RSPLS_CR_EXIT_BASE". Now we want to call a function method "IF_RSPLS_CR_METHODS~DERIVE" like:
    implement your derivation algorithm here:
      field-symbols: <l_chavl> type any.
      assign component 'BW_LAGER' of structure c_s_chas to <l_chavl>.
    CALL FUNCTION 'Z_ST_BW_LAGER'
    The function look like:
    FUNCTION Z_ST_BW_LAGER.
    ""Lokale Schnittstelle:
    *"  EXPORTING
    *"     REFERENCE(BW_LAGER) TYPE  /BIC/OIBW_LAGER
    lesen
    But we did not know wich are the IMPORTING (like I_INFOPROV ?) parameters to fecht the values for the data. In BW-BPS we have UPC_Y_AREA, UPC_Y_VARIABLE, UPY_Y_CHANM and so on. Wich are the same in BI-integrated planning.
    Regards,
    Daniel Meyer

    Dear all,
    we use this code:
      field-symbols: <l_chavl> type any.
      DATA: LAGER(2).
      assign component '/BIC/P_RMRESC' of structure c_s_chas to <l_chavl>.
      IF <l_chavl>+0(3) = 'EMU'.
        LAGER = '2'.
      ELSEIF <l_chavl>+0(1) = 'O'.
        LAGER = '1'.
      ENDIF.
      <l_s_buf>+2(15) = <l_chavl>.
      assign component '/BIC/BW_LAGER' of structure c_s_chas to <l_chavl>.
      <l_chavl> = LAGER.
      <l_s_buf>+0(2) = <l_chavl>.
    But now we have the problem, how to write ist back to the buffer? If we debugg it, we see in this code:
      IF o_use_buffer = rs_c_true.
        o_r_is_valid->* = l_is_valid.
        IF o_r_is_valid->* = rs_c_true.
          INSERT <l_s_buf> INTO TABLE <l_th_buf>.
          c_s_chas = <l_s_buf>.
        ELSE.
          IF e_t_mesg IS SUPPLIED.
            o_r_s_mesg->* = l_s_mesg.
            APPEND l_s_mesg TO e_t_mesg.
          ENDIF.
          INSERT <l_s_buf> INTO TABLE <l_th_buf>.
          RAISE EXCEPTION TYPE cx_rspls_failed
            EXPORTING
              msgid = l_s_mesg-msgid
              msgty = l_s_mesg-msgty
              msgno = l_s_mesg-msgno
              msgv1 = l_s_mesg-msgv1
              msgv2 = l_s_mesg-msgv2
              msgv3 = l_s_mesg-msgv3
              msgv4 = l_s_mesg-msgv4.
        ENDIF.
      ENDIF.
    that o_r_is_valid->* has no value, so he goes to the ELSE-part.
    Could anyone help?
    Regards,
    Daniel

  • How to implement parent entity for core data

    Hi there.
    I am starting a document-based Core Data application (Cocoa) and developed the following data model;
    The 'invoice' entity is a parent entity of 'items', because ideally I would want there to be many items for each invoice. I guess my first point here is - is what I am trying to do going to be achieved using this method?
    If so, I have been trying several ways in Interface Builder to sort out how to implement this structure with cocoa bindings. I have made a Core Data app before, just with one entity. So this time, I have two separate instances of NSArrayController's connected to tables with relevant columns. I can add new 'invoice' entities fine, but I can't get corresponding 'items' to add.
    I tried setting the Managed Object Context of the 'item' NSArrayController to this;
    I thought this would resolve the issue, but I still have found no resolution to the problem.
    If anyone done something similar to this, I'd appreciate any help
    Thanks in advance,
    Ricky.

    Second, when you create a Core Data Document Based application, XCode generates the MyDocument class, derivating from NSPersistentDocument. This class is dedicated to maintain the Managed Object Model and the Managed Object Context of each document of your application.
    There is only one Context and generally one Model for each Document.
    In Interface Builder, the Managed Object Context must be bound to the managedObjectContext of the MyDocument instance: it's the File's owner of the myDocument.xib Nib file.
    It's not the case in your Nib File where the Managed Object Context is bound to the invoiceID of the Invoice Controller.
    It's difficult to help you without an overall knowledge of your application, perhaps could you create an InvoiceItem Controller and bind its Content Set to the relationship of your invoice.

  • Can't we use function to derive value for NEXT clause in MV ?

    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?

    942661 wrote:
    Hi Friends,
    I have a requirement like below
    I need to derive the schedule (Value for NEXT clause in the create MV command) for a MV to run it
    e.g., Value from a date column : 03-JUL-2012 10:00 AM, VALUE for NEXT clause in CREATE MV statement should be 03-JUL-2012 04:45 AM (It is -5.45 hrs from the above date column value )
    So I wrote a function (GET_DATE) to derive schedule for NEXT clause and tried to call it from NEXT caluse, but it is giving error message as mentioned below
    ORA-04044: procedure, function, package, or type is not allowed here
    CREATE MATERIALIZED VIEW child_mv
    PARALLEL 16
    INITRANS 16
    STORAGE (
    FREELISTS 16
    FREELIST GROUPS 4
    BUILD IMMEDIATE
    REFRESH COMPLETE
    NEXT GET_DATE('PARENT_MV')
    AS
    SELECT * from xxmdme_party_stage where rownum<101;
    Could you please help to give some light on how this can be done ?you must (ab)use EXECUTE IMMEDIATE

  • Best way to derive a "week ending" date using the Derived Column Transformations

    Hi, I have an interesting challenge. I am working on creating a BI DB that contains timesheet data. The data contains a column representing the date "worked"  ([Date]. Nearly all output reporting is based on a timesheeting week that end on
    a Wednesday. My thinking has been to create a derived column "WE" (week ending) that represents the entries of the preceding 6 days.
    (Originally I entertained deriving this value view SQL view - however we are talking about a DB that is is a substantial DB (excess of 100M timesheet bookings) and an index on the WE field is warranted) so decided a derived WE column was best approach.
    The Date field is represented from a SAP format (German long dated format) - however I cannot use the convert option ;( in the TE.
    The Date field is derived via: (DT_DATE)(SUBSTRING([Date      ],7,4) + "-" + SUBSTRING([Date      ],4,2) + "-" + SUBSTRING([Date      ],1,2))
    I would welcome some recommendation on how to best derive a WE column. (The DT_DATE format is not susceptible to a /7, mod7 operation).
    Thanks in advance,
    /L

    Try this solution :
    http://stackoverflow.com/questions/1803987/how-do-i-exclude-weekend-days-in-a-sql-server-query

  • Info.plist issues with Core Data

    I created a new project, selecting to use Core Data. However, the info.plist does not include the standard iPhone project options like status bar style and icon gloss etc. I tried copying and pasting the status bar style key and value from another project's plist, but this has no effect.
    Any help would be appreciated please.

    Verduomo wrote:
    I created a new project, selecting to use Core Data. However, the info.plist does not include the standard iPhone project options like status bar style and icon gloss etc.
    Shine is added by Apple now. I get shine without a 'prerendered' key.
    What SDK are you working with?
    Did you add a 'prerendered' key?
    <key>UIPrerenderedIcon</key>
    <true/>

  • Core data refuses to work

    hi.
    I have a very simple model, it contains 1 entity with 4 attributes.
    I have created an ObjectController in IB, and bound it to my persistent document's object context.
    I follow this code (found in the core data documentation)to get a reference to the Object, and to set/get values:
    NSManagedObject *myDoc = [NSEntityDescription insertNewObjectForEntityForName:@"BKSketchDocMO" inManagedObjectContext:[dataSource managedObjectContext]];
    thePanX = [[myDoc valueForKey:@"docPanX"] floatValue];
    [myDoc setValue:[NSNumber numberWithFloat:[self bounds].size.width/2] forKey:@"docPanX"];
    now we come to the problem.
    its doesn't work. theres an entity. I can get a reference to it, and it ALWAYS has the default values. NOTHING i do changes the values, NOTHING i do gives me anything Except the default values.
    and since core data is basically a black box... I CAN"T DEBUG IT.
    can anyone, shed any light on anything that might explain why I can get the object, get values, but I cannot set values?
    signed,
    getting frustrated by the core data double-talk and general lack of any real, and useful documentation.
    Message was edited by: Edward Devlin1

    Hi kids, yet again I have answered my own question. in my application, I could not make my object graph self populate, and then when i did get it to populate programatically, I could not access the data.
    I have solved both problems. one was a conceptual problem, and the other was operator error building off of a conceptual problem.
    first, lets tackle why my object graph doesn't auto populate. in IB i made an Object controller, and I hooked it up to my entity. I told the controller to automatically prepare content. I had assumed that it meant that when my Object Context was instantiated, it would automatically create an instance of my referenced object. this is Not how core data works. Currently i am working under the impression that "automatically prepares content" mean that when an entity is instantiated, it will fill out the appropriate values, with the defaults you set up in your object model.
    so core data Does not actually instantiate anything for you. once I made this conceptual leap, I was still hazy on the implementation. I tried adding new entities upon initialization, but that tended to over-write entities opened from a saved document. in the end, I simply settled on making sure the entity existed when i tried to access its information. If it didn't exist I made one before trying to access it. in practice, this is a very slick and robust solution.
    now for problem #2... every time I tried to access my data, it is like it was zeroed out to the default settings.
    well, thats exactly what was happening. my entity was valid, I was making changes to it, and I was still getting the default values back. How was this happening? I didn't understand what i was doing.
    heres what I thought was happening. I thought I was making a new ManagedObject, and filling it with the values of the entity I was trying to access, then I got the values from that ManagedObject, and discarded it.
    What was really happening: If you look at my code, you'll see a method called : "insertNewObjectForEntityForName:" this is the method I THOUGHT was going to my ObjectContext, getting my entity and creating a ManagedObject from it for me to interface with. Clever coders will see the problem right away. Insert new Object? I was creating a new instance of my entity each time i Thought I was accessing the original. holy crap! of course I was only getting the default values... and sure I was able to make a change to the values, but the next time I tried to access them, I would just get a new entity, filled with default values!
    so InsertNewObject, was the wrong approach... what turned out to be the correct approach? heres why i was having such a bad time of this... NSDictionary, is roughly analogous to Core Data. I have alot of experience w/ NSDictionary, and so i expected a straight forward... give me an object based on this key method. I understood that i was going to have to work through a proxy, but I had assumed a little too much about how Core data works. its not like NSDictionary at all. it works much more like a search engine... you tell it where, and what to look for and it will bring you back a list of things that are kinda like what you're looking for.
    This is called a fetch request. Its a much more elaborate way to look for stuff than a simple objectForKey: method. its how you get your information from core data. Information comes back as an array of NSManagedObjects. The documentation made everything so much more difficult because it spoke of fetched values as something extra or added on to core data. Kids say it along w/ me.... fetch requests are how you get info from core data. repeat.

  • Core Data questions (NSNumber)

    Hi,
    I'm a bit lost with cocoa programming (have done C/C++ in University, now trying to get into the whole user interface thing). I'm trying to do a simple Core Data application but there are things I don't understand.
    First, I have an NSForm in my main window. I'd like the user to enter values in those. But, one of my entitie's attribute should be an interger. The thing is, the values in an NSForm field is a string. I know I can switch the attribute's type to string, but is there a proper way of doing this?
    Second, I have an NSTextField that shows an integer (again it's a string, I'd like it to be an integer). I placed a button next to it to increment that number by one each time it's clicked. At the same time, that field is binded to an attribute wich I'd like to be updated each time to keep track of everything. How do I program the incrementation thing in cocoa? I know Objecive-C quite a bit, but I don't know how to get the job done (what to connect to what, where to put my code, what to overide, etc...).
    Any help would be appreciated!

    Well, first of all, most interface components in Cocoa inherits from the class NSControl, in this class you can fin the method -intValue and -setIntValue: to respectively get and set an int value, if you send an -setIntValue: message to a text field it'll display your integer as a string. If you send a -intValue message to a text field it'll try to parse the number in the text field and will return it or 0 otherwise.
    For your incrementing I would tell you to use bindings, but in that case I would let you read the Apple Documentation because I never really use it so I can't explain it properly.
    So, I'm going to tell you the traditional way to make that work. According to MVC design pattern (Model-View-Controller), you would use 3 levels, but I'll make it simpler and use only 2.
    You have to create a new class which will be a Controller, to do this you go into Interface Builder, in the MainMenu.nib you click the Classes tab, you select NSObject in the left column, you go Classes menu and you do "Subclass NSObject". You put a name for your class.
    Then you open an inspector window, you go in Attributes part where you can see outlets and actions. You add one outlet for your text field of type NSTextField, and you add one action named increment: (the colon is added automatically).
    Then you click on your class again in the MainMenu.nib Classes tab and in the Classes menu you choose Instantiate <your class name>. You'll see a blue cube appear in the Instances tab.
    You hold ctrl key and click on the cube then you drag to your NSTextField (a line should appear between the cube and the cursor) you drop the line on the NSTextField and connect the text field to the outlet in your inspector window.
    You do the same for the button, except that this time you drag from the button to the blue cube and you select the action you defined earlier.
    There you are, everything is set up in IB, now go back into the Classes tab, select your class again and in Classes menu choose "Create files for <your class name>", choose your project and validate. Close IB and save your nib, go on Xcode, select <your class name>.m and inside it put the code into your increment method :
    [textField setIntValue: [textField intValue] + 1];
    textField should be replaced by the name of the outlet you put. Then you can execute and you'll have a beautiful text field which value will be incremented by clicking on the button.
    You can check the Cocoa Tutorial in Apple documentation, there's way more in it than in my post, and there's illustrations to make everything clearer.

  • Core data and Populate field programmatic

    Hi
    On a window i have a couple of controls Combo box, Text field and a few buttons
    all linked to core data which is working perfect ish
    if I select the combo box and change the value its updated in core data straight away
    if I press a button it put a value in the text box but doesn't update the code data field until i click in the field and add a space or something simular ..
    is it a focus thing, the field don't lose focus until I have done it manually
    can someone point me in the right direction for this
    just want to click a button , put that value in the textbox and core data is updated without having to click in the text box
    regards
    Tony

    Does this help?

  • Core Data Document Icon

    Hey guys,
    I have a document based Core Data application here. When I save a file as Binary/XML I get a standard blank file icon. How do I make sure the user sees a custom icon when saved from my app?
    TIA,
    Ricky.

    rickydamelio wrote:
    I have a document based Core Data application here. When I save a file as Binary/XML I get a standard blank file icon. How do I make sure the user sees a custom icon when saved from my app?
    You do this for a Core Data app just like you would for any other Cocoa application. And with a core data app most of the details should already be set up for you.
    Check out Storing Document Types Information in the Application's Property List for more info.
    First you need to create a .icns file containing the icon you want to use for your document. Then add the icns file to the Resources group of your Xcode project so when you build it will get copied into your application bundle. You can create a different .icns file for each type of document, or you can use the same icon file for all your document types if you want them to have the same icon.
    Next, expand the "Targets" group in Xcode, select your target and click the "Info" button in the toolbar. Select the "Properties" tab of the Info window. A core data app should already have three document types set up in the list at the bottom the window. Edit the "Icon File" column and add the file name of your .icns file for each document type.
    You may want to edit the "Name" column as well. Whatever you put here is what will show up as the "Kind" in the preview column if you select one of your documents in column view or if you do a "Get Info" on one of your documents.
    You can also change the "Extensions" column and the "OS Types" column to uniquely associate your documents with your application. But note that if you change these values then your application may have trouble opening _pre-existing documents_ that were created with the original extensions or types. You could manually rename an existing document to remove the old extension and add the new one. Or use the SetFile tool if you needed to change an pre-existing document's OS Type.
    The Finder probably won't pick up on these changes right away. You may have to logoff and log back on or force Finder to restart before your changes will be recognized.
    Steve

  • Core data binding not working

    in my project I used core data and binding to produce data on document based program.
    I have used multiple entities and they worked fine and then they stopped working and I don't know why.
    all the text fields now have "()" in them with space in between them, and will not add to the database.  so the field shows a junk value and will not bind properly to the database.
    how would I start to debug this I have been searching but I don't know where to start, mainly i dont know what the problem is.

    Binding works one way. This means that textInput.text changes
    to match the value of account.identifier, not the other way around.
    While I think it's theoretically possible to create a binding the
    other way (I haven't played with binding in ActionScript), it makes
    more sense to listen to the TextInput's change event to get changes
    to the text field.
    Or, you can create a model in the MXML and bind one its
    properties to the textinput's value. Look in the docs about the
    mx:Model tag for details.

  • Core Data PopUp won't populate...Please HELP!!!

    Hi all.
    Working through the Core Data Relationships Chapter 30 of Hillegrass' book.
    Can't get the Departments.xib, tableView Department column to populate the PopUp.
    Checked rechecked bindings, rebuilt the Xib five times. even Re-did the Relationships.
    Not sure add is calling..
    - (void)addEmployeesObject:(Employee *)value
    When add employee I can add first and last but Only: "No Value" available
    Any ANY hints or help would be greatly appreciated.. been on this chapter for two weeks!!!
    and it's freaking me batty!!!
    Help! thanks.
    Ian

    I'm actually on those forums a lot.
    and
    I downloaded the example files..
    and it actually generates an error.. after the second employee entry..
    HIToolbox: ignoring exception 'Unacceptable type of value for to-one relationship: property = "department"; desired type = Department; given type = Employee; value = <Employee: 0x2478d0> (entity: Employee; id: 0x246730 <x-coredata:///Employee/tE2856ABB-4F2A-4A98-BCB8-957B88DE47194> ; data: {
    department = nil;
    deptName = nil;
    employees = (
    firstName = jazz;
    lastName = fm;
    manager = nil;
    }).' that raised inside Carbon event dispatch
    etc....
    also noticed that every new entry generates a extra blank department entry kind of odd..
    also Rebuilt rebound this many times, in fact so many times, my pages are coming loose.
    but thanks, really do appreciate any help I can get..
    basically My tableview column doesn't popup with anything but "No Value"
    and won't let me select anything.. which is why I think
    - (void)addEmployeesObject:(Employee *)value
    isn't being triggered..
    well thanks..
    Ian

Maybe you are looking for