Saving NSDatePicker to a string and saving that to NSUserDefaults...

Saving NSDatePicker to a string and saving that to NSUserDefaults I have it saved to a string then I have code that should save it to NSUSerDefaults so that when the program starts it is saved as the string not null. Here is the code [CODE]#import "MainView.h"
#import "DateView.h"
@implementation MainView
-(void)awakeFromNib
[self removeFromSuperview];
[self addSubview:dateView];
[dateView setdateandtime];
[dateView permsavedattime];
@end [/CODE] [CODE]#import "DateView.h"
#include "MainView.h"//Use #import this is to see if #include Works
@implementation DateView
-(IBAction)showuserdefaultdate
[self userdefaultdate];
//dateoutput.text =tddate;
-(void)permsavedattime
tddate=[prefs stringForKey:@"testing"];
tdtime=[prefs stringForKey:@"timetesting"];
dateoutput.text =[[NSString alloc] initWithFormat:@"%@",tddate];
-(void)userdefaultdate
prefs =[NSUserDefaults standardUserDefaults];
[prefs setInteger:tddate forKey:@"testing"];
[prefs setObject:tdtime forKey:@"timetesting"];
-(void)setdateandtime
[Today setDate:[NSDate date] animated:YES];
//formatting date style
dateformatter = [ [ NSDateFormatter alloc ] init ];
[ dateformatter setDateStyle:NSDateFormatterLongStyle];
[ dateformatter setTimeStyle:NSDateFormatterNoStyle ];//makes it so the time is not included
//[ formatter setTimeStyle:NSDateFormatterLongStyle ];//set to anystyle besides
//NoStyle if you dont want time included.
[Time setDate:[NSDate date] animated:YES];
//formatting date style
timeformatter = [ [ NSDateFormatter alloc ] init ];
[ timeformatter setDateStyle:NSDateFormatterNoStyle];//makes it so it doesn't get the date
[ timeformatter setTimeStyle:NSDateFormatterShortStyle];//makes it so the time is just hour and minute and A.M. or P.M.
//[ formatter setTimeStyle:NSDateFormatterLongStyle ];//set to anystyle besides
//NoStyle if you dont want time included.
-(IBAction)recieveDate
tddate= [dateformatter stringFromDate:Today.date];//Asigning the date to the string
dateoutput.text =tddate;
-(IBAction)recievetime
tdtime= [timeformatter stringFromDate:Time.date];//Asigning the date to the string
timeoutput.text =tdtime;
-(IBAction)canceltime
[Time setDate:[NSDate date] animated:YES];
tdtime= [timeformatter stringFromDate:Time.date];//Asigning the date to the string
timeoutput.text =tdtime;
-(IBAction)canceldate
[Today setDate:[NSDate date] animated:YES];
tddate= [dateformatter stringFromDate:Today.date];//Asigning the date to the string
dateoutput.text =tddate;
@end[/CODE] What am I missing? It keeps coming up Null I need it saved right so I can send it through email

softwarespecial wrote:
why can't I have the prefs saved in the .h
You can save that address in an ivar if you want to, but there's no purpose to that. The standardUserDefaults object is a +shared class object+. It's like a dictionary object that's maintained for your program by the NSUserPreferences class. You can read from or write to it at any time for the duration of your program. So whenever you get the shared object's address [NSUserDefaults standardUserDefaults], you're just getting the address of that same object each time.
In case the above doesn't make sense, I ran across a good explanation by Danneman in the last message on this page: [http://www.iphonedevsdk.com/forum/iphone-sdk-development/18716-set-settings-va riable-code.html].
When I did that as you so wisely pointed out it didn't work but when I saved it at each point I needed it it works.
When you change two things at once it's easy to forget the first and assume the second change solved the problem. Actually, I don't think saving prefs in your ivar had anything to do with your bug. What fixed it was getting a pointer to the shared std defaults object in this method:
-(void)permsavedattime
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; <-- get the shared object
tddate=[prefs stringForKey:@"testing"];
tdtime=[prefs stringForKey:@"timetesting"];
dateoutput.text =[[NSString alloc] initWithFormat:@"%@",tddate];
Without the first line of the above, I'm fairly sure that your prefs ivar was nil. I didn't see any code that initialized that ivar prior to the first time userdefaultdate ran. It looked to me like permsavedattime ran at start up, well before prefs was set in userdefaultdate. If you're interested in backtracking, restore the file to the way it was when you posted, then add a NSLog() like this:
-(void)permsavedattime
// NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; <-- get the shared object
NSLog(@"prefs=%@", prefs);
tddate=[prefs stringForKey:@"testing"];
tdtime=[prefs stringForKey:@"timetesting"];
dateoutput.text =[[NSString alloc] initWithFormat:@"%@",tddate];
I wish to save lets say five different things to NSUSerDefaults would I be able to do it all with my NSUserDefaults prefs or would I have to create a another one for some of them?
You know the answer to your second question now, right? The important point is that you're never creating the shared object, you're just asking for its address whenever you need it.
Btw, there's another user defaults method you should know about: The synchronize method writes the data to disk. You might want to do that when your app is ready to exit. E.g., in the app delegate:
- (void)applicationWillTerminate:(UIApplication *)application {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs synchronize];
Although the docs suggest synchronize when the app is about to exit, I'm not sure it's necessary. I think the system might write the defaults out to disk anyway when the app terminates, but not sure about this. +User Defaults Programming Topics for Cocoa+ says:
On Mac OS X v10.5 and later, in applications in which a run-loop is present, synchronize is automatically invoked at periodic intervals. Consequently, you might synchronize before exiting a process, but otherwise you shouldn’t need to.
The above is in the iPhone edition, so I think it applies.
It might also be a good idea to update the data and call resetStandardUserDefaults in didReceiveMemoryWarning. I'm not clear about the need for reset either though, since the system may do that for you as well. But on a memory warning, you would definitely want to update the user default data if some of it is stored in an object to be released. You can find out how your app behaves on a memory warning by selecting Hardware->Simulate Memory Warning from the iPhone Simulator menu.
- Ray

Similar Messages

  • How do I add a record's primary key to a query string and add that to an .xml catalog?

    Hello everyone,
    I am using Dreamweaver CS3 on a MacBook Pro Leopard 10.5.6 and MAMP 1.7. I am also teaching myself how to work with PHP and MySQL, using David Powers book The Essential Guide to Dreamweaver CS3.
    I am trying to create a wedding photography web site, with a personal page after login, which will display the photographs of the customers wedding.
    The same page will also be a catalog/shopping cart, so the customer can choose which photo's they want, and pay for them. (I am aware that there are instructions in The Essential Guide in chapter 15 page 515, on how to redirect to a personal page, but it doesn't fully cover what I am asking).
    I have already created the login success page, which greets users by name, as per the instructions in The Essential Guide. I have also created a catalog page. However my catalog page is not calling information from the database, instead it is taking information from an XML page using PHP.
    I would like to insert a list menu on the login success page, which lists the customers name, and when they select their name they will then select a link that will take them to a personal page with just their wedding photographs.
    I am unsure of how to pass the customer_id, in what will be the username list menu, to the page which will contain the customers set of wedding images.
    Is it the same process used in chapter 14 where you add a record's primary key to a query string?
    I am asking because when I set up a recordset from the MySQL database it lists the images as witten names not actual images, I have tried calling the images with PHP code but it just doesn't work.
    The catalog page I have set up at the moment is not calling the images from the database, but directly from the image folder.
    Is what I am trying to do possible?
    If so how do I pass the customer_id and username to a recordset and link that recordset to the xml catalog so the customers personal wedding images are displayed on the catalog page for the shopping cart?  I need step by step instructions, or maybe a link to a good tutorial.
    Can somebody help me please?
    Thankyou.

    QuickTime 7 can set the poster frame, but I've not had much success with it. This is what QuickTime 7 Help says about this topic:
    +A "poster frame" is a still image of a movie that represents the movie in places like the Finder. The default poster frame is the first frame in the movie. You can change the poster frame.+
    +To change a movie's poster frame:+
    +In QuickTime Player 7, drag the playhead (or use the arrow keys to move the playhead) to the desired frame.+
    +Choose View > Set Poster Frame.+
    +To view a movie's poster frame, choose View > "Go to Poster Frame."+
    If you don't have QuickTime 7 (version 7.6.6) it can be installed from your Snow Leopard disc using a custom install. Otherwise download it from this Apple site: http://support.apple.com/kb/DL923
    John

  • HT5824 I've been using numbers for iPad and I accidentally deleted a column. And the auto-save feature saved that and now I can't undo it. Does iCloud storage have backups of saved files from like 10 minutes ago? I have number

    I've been using numbers for iPad and I accidentally deleted a column. And the auto-save feature saved that and now I can't undo it. Does iCloud storage have backups of saved files from like 10 minutes ago? I have numbers synced to iCloud.
    I tried to undo it but the app crashed.
    I am hoping there's like a previously saved version of my file in iCloud somewhere. 

    No, iOS does not do short term incremental back ups to iCloud such as you get with Time Capsule.It backs up when you do soo manually, or if set properly, when the device is plugged in and connected to WiFi. It will not have saved your changes as of 10 minutes prior.

  • How do I set numbered lists for headings in Pages 5.2, and keep that system of numbered lists saved?

    I have tried to set numbered lists for headings in Pages 5.2 but have not succeeded. I have read similar questions concerning this but this has not helped me...
    When I say numbered lists I mean something extremely important and simple, for instance:
    1. Introduction
    1.1. Background
    1.2. Purpose and Questions
    2. The Legality of Clause X
    2.1. Legality under Article 101.1
    2.2. Legality under Article 101.3
    And so on...
    Heading 1. is selected as "Heading", 1.1 is selected as "Heading 2", and if I had 1.1.1 it would be selected as "Heading 3" and so on...
    I have navigated my way to the Format window, and under the tab "Style" and down to "Bullets & Lists". I have here selected the following: Numbered, Numbers, 1. 2. 3. 4., Tiered Numbers, Continue from previous.
    There are several problems with this currently.
    First, based on the example it becomes "2. Background" when it should be "1.1 Background" instead.
    Second, after writing some body text between the headings and then select a new heading, all the previously selected settings I mentioned above in "Bullets & Lists" have to be reselected.
    So, how do I set numbered lists for headings, or so called sub-headings, in Pages 5.2? And how do I keep that selected system of numbered lists saved so I don't have to retype it for every new heading I type? (e.g. so that Pages knows that every time I choose Heading 2, I want it to number the heading in the way selected)
    Obviously, manually writing the numbers for every heading is not a viable option, as it makes table of contents problematic and is simply tedious. You need an automatic way of doing it, especially if you write long documents where keeping headings in order is absolutely essential.
    Also, reverting back to previous Pages versions (like v. 9 I think?) is not an option as that does not exist on my recently purchased Macbook Pro.
    I need to be able to do this on Pages 5.2 and do it automatically.
    I appreciate any help with this.

    iWork '09 is not "outdated" it still works and works extremely well and whilst not perfect with MsWord it is far far better than Pages 5.2 which has a stream of major issues with exporting. It is also way better and faster to use than Microsoft Office.
    So what is your time and work actually worth? If it is less than $19.99 for 6 months, you may as well just chuck it in and take that job on minimum wages.
    You are assuming things for Office 2014 with absolutely no inside knowledge. Much as we assumed Pages 5 was going to be the long awaited improvement, but ended up being a downgrade to match the iOS version, Microsoft is headed the same way with their mobile versions.
    This is not like getting the "latest" pair of pants where you go with the crowd and throw out your cigarette legs which replaced the flares, which replaced your low cuts which replaced your cigarette legs, which replaced…
    This is work.
    If it does the job and does it well, use it. There is nothing out there to really match what Pages '09 does. Yet.
    LibreOffice can do most but not all, but has a UI that only a mother could love. It's great redemption is that it uses both open formats and the standard Microsoft formats and is under active development. It also opens and saves to just about everything. When they finally work out the Pages formats, I'm sure they will open those as well.
    I use a lot of professional software. Just because the publisher's marketing department says change the product so we can sell more, doesn't mean you have to pay any attention whatsoever. Adobe being a classical example. Most designers are just ignoring their latest subscription based bloatware and getting on with their work.
    Peter

  • When i switch from my old iphone to the 5 do the photos i have in apps like vsco and campera   that have not been saved in my photostream transfer over as well?

    when i switch from my old iphone to the 5 do the photos i have in apps like vsco and campera   that have not been saved in my photostream transfer over as well?

    Full Details here...
    Old Phone to New Phone
    http://support.apple.com/kb/HT2109

  • I had an older version of Firefox on older Mac OS 10.3.9. Tried to update. Crashed the Mac. Lost things saved on my desktop and Firefox that I had benn using for years is gone. Is there an older version I can reinstall?

    I had an older version of Firefox on older Mac OS 10.3.9. Tried to update. Crashed the Mac. Lost things saved on my desktop and Firefox that I had benn using for years is gone. Is there an older version I can reinstall?

    Hello kc9agz,
    Thank you for contacting Mozilla Support. Did you back up your bookmarks before you moved to the new computer? You can find more information about backing up and restoring bookmarks in this article.
    [[Restore bookmarks from backup or move them to another computer]]
    Please let us know if this solves your issue.
    Cheers,
    Patrick

  • I am having trouble saving my swatches and brushes that I create. After I close Illustrator, and come back later my swatches and brushes are gone.

    I am having trouble saving my swatches and brushes that I create. After I close Illustrator, and come back later my swatches and brushes are gone.

    Once you have a document with the swatches, brushes, symbols that you want, save it as a new Document Profile.
    Document profiles can be found (and saved) in Library > Application Support > Adobe > Adobe Illustrator 18 (if you have CC) > your language folder > New Document Profiles.
    Next time you create a document you will find it in the list of profiles.

  • Just upgraded to Mac Lion... can't access Appleworks6...get this message... "You can't open the application AppleWorks 6 because PowerPC applications are no longer supported".... I've got dozens of documents saved that I can't access?!!!!!

    Just upgraded to Mac Lion... can't access Appleworks6...get this message... "You can't open the application AppleWorks 6 because PowerPC applications are no longer supported".... I've got dozens of documents saved that I can't access?!!!!!

    Rosetta is not included Lion, if you are not familiar with Rosetta it was an application included in Tiger, Leopard and Snow Leopard that allowed PPC based apps to run on Intel based machines. That was over 5 years ago so it's time to move on. As has been suggested you can read those documents in Pages which is available on the App Store. Pages is part of the iWorks suite that replaced AppleWorks years ago. Currently iWorks is on iWorks 09 , and includes Pages, Numbers and Keynote. You can find each on the App store.

  • Hi , how i can print attachment from macbook , i also saved that attachments but cant find print option

    hi , how i can print attachment from macbook , i also saved that attachments but cant find print option

    Normally one would open the attachment in the appropriate application (e.g., MS Word for a Word document, Preview for a PDF, etc.) and use that application to do the printing.

  • Does iCloud save voicemail messages from my iphone 5 when I back up? More specifically I am trying to access messages that were in my deleted folder at the time I last saved, that have since been cleared.

    Does iCloud save voicemail messages from my iphone 5 when I back up? More specifically, I am trying to access messages from my now deceased father that were in my deleted voicemail folder at the time I last saved, that have since been cleared.

    The iCloud backup includes visual voicemail messages.  I'm not sure if it includes the deleted ones or not, but I would assume it does.

  • Can I call a function from a dll in LabVIEW that returns:double*string and int.?

    I have a function from a dll that return a double* string and an integer. How can I call this function from LabVIEW? There is a possibility to work in LabVIEW with a double* string?

    pcbv wrote:
    > Hello all,<br><br>The header of the function is:
    >
    > "HRESULT WRAPIEnumerateDevices(WRAPI_NDIS_DEVICE **ppDeviceList, long *plItems);"
    >
    > where WRAPI_NDIS_DEVICE have this form:
    >
    > typedef struct WRAPI_NDIS_DEVICE<br>{<br>
    > WCHAR *pDeviceName;<br>
    > WCHAR *pDeviceDescription;<br><br>}
    > WRAPI_NDIS_DEVICE;<br><br>
    >
    > The function is from WRAPI.dll, used for communication with wireless card.
    > For my application I need to call in LabVIEW this function.
    Two difficulties I can see with this.
    First the application seems to allocate the array of references
    internally and return a pointer to that array. In that case there must
    be another function which then deallocates that array again.
    Then you would need to setup the function call to have a pointer to an
    int32 number for the deviceList parameter and another pointer to int32
    one for the plItems parameter.
    Then create another function in your DLL similar to this:
    HRESULT WRAPIEnumExtractDevice(WRAPI_NDIS_DEVICE *lpDeviceList, long i,
    CHAR lpszDeviceName, LONG lenDeviceName,
    CHAR lpszDeviceDesc, LONG lenDeviceDesc)
    if (!lpDeviceList)
    return ERROR_INV_PARAMETER;
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceName, -1,
    lpszDeviceName, lenDeviceName,
    NULL, NULL);
    if (lpDeviceList[i].pDeviceName)
    WideCharToMultiByte(CP_ACP, 0,
    pDeviceList[i].pDeviceDescription, -1,
    lpszDeviceDesc, lenDeviceDesc,
    NULL, NULL);
    return NO_ERROR;
    Pass the int32 you got from the first parameter of the previous call as
    a simple int32 passed by value to this function (and make sure you don't
    call this function with a higher index than (plItems - 1) returned from
    the first function.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Is it possible to save an iPhone back up and access the files later if needed?  I have a string of text sms and iMessages that I would like to save and then delete them from my phone.  Is this possible?

    I have a string of text sms and iMessages that I would like to save and then delete them from my phone, but gain access to them later if I need them.  I prefer to have the string with the date/time stamp vs copying and pasting into a doc or text file.  Is this possible?

    Not unless you buy an app that accesses data from an iTunes backup.  Check in the app store.

  • When I forward an e-mail, I get a long string of gobblygook that goes with it and I cannot figure out how to eliminate it without having to delete it every time

    When I forward an e-mail, I get a long string of gobblygook that goes with it and I cannot figure out how to eliminate it without having to delete it every time I forward an e-mail. The following is only part of the string that I am talking about. How can I eliminate this from the e-mail?
    Here is part of an excerpt from one of the strings:
    From: - Mon Aug 19 18:12:47 2013
    X-Account-Key: account1
    X-UIDL: 065B31352CC6B3C0789DEA7954395B55
    X-Mozilla-Status: 0001
    X-Mozilla-Status2: 00000000
    X-Mozilla-Keys:
    Return-Path: <[email protected]>
    Received: from hrndva-mxlb.mail.rr.com ([10.128.255.126]) by hrndva-imta07.mail.rr.com with ESMTP id <20130819211326470.DBUO12525@hrndva-X-Roving-StreamId: 0

    Sorry, Firefox doesn't do email, it's strictly a web browser.
    If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
    If your problem is with Mozilla Thunderbird, see this forum for support.
    [https://support.mozillamessaging.com/en-US/home] <br />
    or this one <br />
    [http://forums.mozillazine.org/viewforum.php?f=39]

  • Code of Conduct ESS - Where is saved that the employee accepted?

    Hello,
    (Version of ESS 1.0 for ERP2005)
    The code of conduct is working perfectly, the employee accept the Code of Conduct (Using the standard workflow WS31000009). He/she can only accept once and after that he/she have a message saying that he/she already acceptes the code of conduct.
    My dought is where the Department of Human Resources knows what employees accepted the code of conduct, in transaction PA30? What infotype?
    Can anyone help me?
    Thanks in advance.
    Sonia

    Thanks a Lot Christopher
    I look to the Function Group HRESS_FORMS_SECC
    I saw that the IT0035 is the one, but how do you know that is Subtype 03?
    Can you please tell me where you found it?
    Thanks a lot for your help
    Sónia
    Sorry I already found!!
    In function HRESS_FORMS_WRITE_IT0035
    Thanks for your help
    Message was edited by:
            Sonia Santos

  • Pass Values to Edit Form thru Query String and Save in List

    I have developed a custom Edit form from SharePoint Designer and I am passing values thru Query String as below;
    http://<>/cli/acc/Lists/GIInfo/testEdit.aspx?ID=262&com=POD_Send
    And, user supposed to save the form directly without changing the values came thru Query String as below. 
    Now, issue is, when user saves the form, values is not getting saved. It saves when we change the value in text box or when we do a text change event in form. Becasue data binding says Text Change even in data binding property.
    __designer:bind="{ddwrt:DataBind('u',concat('ff22',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Actions')}"/>
    Kindly guide me what is the issue, or correct approach to do that? I want to pass values to Edit Form thru Query string and save in List without changing those.
    -Rajesh A.

    I know this is late, but i found a very good solution on this post and credit goes to the author.
    https://social.msdn.microsoft.com/Forums/sharepoint/en-US/4be1be38-0663-4b80-8f28-45f38f98f9d0/sharepoint-designer-2010-custom-newformaspx-data-in-textbox-fields-dont-save-on-submission?forum=sharepointcustomizationprevious
    The issue was resolved by changing the textbox values,
    <asp:TextBox runat="server" id="ff1{$Pos}" Name="Title" Text="" Value="{$Destination}"  __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}">
    instead of
    <asp:TextBox runat="server" id="ff1{$Pos}" Name="Title" Text="{$Destination}"  __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}">

Maybe you are looking for

  • OIM 11g Modify User Profile for Updating End Date

    Hi Gurus! We have an OIM implementation where users may request the creation of other users by means of a Create User request template. In this template we set the End Date to be 3 months after the request date. In order for the requester to extend t

  • Passing values to include program

    HI, Need help on following. in my program A : DATA: BEGIN OF it_qlqua OCCURS 0.         INCLUDE STRUCTURE lqua. DATA:   altbatch TYPE ausp-atwrt,         v_verme TYPE kwmeng. DATA: END OF it_qlqua. INCLUDE zprogramB. perform check_lqua tables it_lqua

  • Installing PHP on FMIS 3.5

    I've recently installed and set up a FMIS 3.5 setup and my web developer wants to have php on the server to create some dynamic content.  Trouble is, I can not for the life of me get PHP to work on the server.  Is there some special instructions that

  • Portege R600 - where can I find the correct SATA drivers?

    I wish to install a solid state drive, and to maintain XP. Setting the correct partition alignment in the SSD and electromechanically installing it are now easy, but there is apparently a SATA driver problem because I cannot boot to either the Toshib

  • Uninstalling of Business Content

    If business content of any cube and related objected are installed by mistake, can the same be uninstalled. Can any one suggest a way out. Regards PVD