How to add notes functionality in myApp in iphone? - iphone

I want to add notes functionality in myApp in iphone so that whenever i would open that notes in future,I would get that along with the date and time of writing that note.
Edit-1:
I want to make notes in my application. I also want to add edit functionality in that notes so that whenever i will open that in future I would be able to edit that and store that for the future with time and date of editing that notes.So i want to make list of the notes which i would make for myself in my application.Please help me regarding this.Thanks in advance and ask whatever u want to give the answer of this question.

What you're trying to do seems very simple. There are SEVERAL ways to go about doing something like that. A couple options off the top of my head:
Create a "Note" object with properties like:
NSString note;
NSDate lastEdited;
And just store it in a file. So whenever the user modifies your data just go:
lastEdited = [NSDate date]; To set the date to the current time.
Personally the way I would handle this is to persist(store) the data in Core Data. That way instead of having to write your data to file each time it's modified you can save the data in one line of code:
[myNote.managedObjectContext save:&error].
I hope this helps. If not there's a similar question that has already been answered here:
Save object in CoreData

Related

iPhone Dev - Creating a one time UIAlertView like in Temple Run

You know how Temple Run sometimes has alerts when you open the App that appear even though you don't update the App? I understand how you would implement this if you were to submit an update to your App, but how does Imangi implement new alerts without releasing new versions of the App? (I'm assuming they upload it from some server, but I'm an amateur at all of that stuff so could someone sorta vaguely explain how I might go about doing that? Will I need to learn Internet programming languages :O?)
Thanks.
I agree with Jonathan. I would set a plist with a reference number on your server. and it would look something like this. I'm using concept, not code. It would be as simple as hosting it on your server. Or it could be as complicated as your creating a user interface on your website that allows you to just plug in the information and it would create the plist for you.
-(void)checkanddisplaynotificationbasedonupdatedplistontheserver{
int currentnotificationnumber = userprefs preference for item "notification"
get and parse notification.plist from your server
notificationnumber = object at index 0
if notificationnumber > currentnotificationnumber{
display your notification with parsed plist
}
}
You could host a plist online, with an array of alerts stored as dictionaries, with attributes like 'title', 'body' etc. The app would then parse this and to create an alert. You could then set up a method which searches for updates to this file every time the app opens and has connectivity.
This is not the only way - there are probably hundreds of other files types/ automated systems to use, however this is a simple way, and roughly how all of them work, and I have implemented something like this in some of my apps. Hope this helps, if you wan't any help coding it, I will be happy to help!
Jonathan

trying to use coredata with an object class ** unsuccessfully**

I am completely lost trying to set up core data to be used inside my nsobject class. I am adding coredata to my existing project so its quite hard to figure this all out. Because of this I have started a new project with coredata to get the sample code I need to implement coredata in my current app.. however I am wondering what alterations do I need to make in order to use this coredata sample code with an object class instead of a view controller/tableview which is what the template code is doing?
To help answer my question I will explain what I am doing with my project at the moment.
I have several viewcontrollers that display different sets of data, because I have a custom database engine I am having to communicate with I have two classes that I have made. One is a request class which creates a packet with all sorts of data that gets sent off to the DBEngine using NSURLRequest/NSURLConnection.
I am using NSURLRequest/NSURLConnection delegates in my custom request class, so when send my request off to the DBEngine i wait until I get a response inside connectionDidFinishLoading delegate method, which I then pass the response data over to my responses class like so....
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
// depending on what sorta request is made will depend on how the data shuld be handled.
if ([methodName isEqualToString:#"GetDBVersion"]) {
//tbc
}
else if ([methodName isEqualToString:#"GetManuf"])
{
[engineResponses GetManuf:receivedData];
}
else if ([methodName isEqualToString:#"GetNonM"])
{
[engineResponses GetNonM:receivedData RestrictionID:RestrictionID];
}
}
By doing this I am creating a new instance of my engineResponses class, which Is okay untill I try to pass the context from the application delegate over to this same class thus creating another instance which equals to things not working....
So as stated above I am wondering how I can edit the template code to work in my favor... I hope I have been clear in my explination I have just spent the last hour on trying to get this question perfect as I have spent the last two days chasing my tail trying to figure this stuff out.. its the first time I have worked with coredata and im just finding it hard to come to grips with it because I seem to be using it in an unconventional manner....
any help would be HUGELY appreciated.. if you need any more code example or better explanations please ask.. I will do anything I can to get help..
Okay So I found out the problem was with declaring multiple instances of the same object.. So all I had to do was use a singleton design patter to get it working perfectly.
Alot of people dislike singletons but I am not sure how else to get around this issue???? any suggestions would be greatly appreciated.
Also I know this worked because I have since checked the DB by logging the storeURL in the appdelegate, then copying pasting that dir, into the goto file - then opening up the sqlite db in xcode.. all the values are in there perfectly.

UIManagedDocument example / tutorial

I have been trying very unsuccessfully to create a simple UIManagedDocument library style application (separate documents saved to iCloud).
I am confused with the following:
Do I subclass UIManagedDocument and set up the persistentStoreCoordinator, ManagedObjectModel & ManagedObjectContext within this subclass, or are these supposed to be configured within the AppDelegate (and if so, how do I go about refreshing the persistentStoreCoordinator to look at the new file - it seems that once that has read a persistentStore that I can't get it to read a new persistent store)?
Richard's example is an excellent example. I used it and the PragmaProg book on core data http://pragprog.com/book/mzcd2/core-data as a guide for creating my managed document module on github.
See: https://github.com/dtrotzjr/APManagedDocument
My code makes use of iOS 7 iCloud Core Data behavior which I cannot comment on publicly until the NDA is lifted. Feel free to ping me directly if you have any questions.
I've just posted a project based on Rick Warren's example: MultiDocumentPlusUUID. In his "Syncing Multiple Core Data Documents Using iCloud" post, Rick writes:
Another bug often shows up when I start trying to pass changes back and forth between devices that both have the same file open. The first sync always seems to work--and it seems to work pretty well as long as each subsequent sync is in the same direction.
MultiDocumentPlusUUID compiles and runs on iOS 7.1b4, and can ping-pong updates to a given document successfully.

iphone coredata with two xcdatamodel

I've been working with core data (successfully ;) , following some tutorials and kind of getting all, but now I have a question about some basic tutorial I found some time ago (the author is not responding so here we go!)
this is the tutorial, and the code for it is here
in this tutorial, there are 2 xcdatamodels??, why? what is the timeStamp on the Event does?? I checked it in sqlitemanager, and after creating some data, timestamp doesnt save anything,
so was it a mistake to leave the Event entity? with its datamodel?
or is there something Im missing?
thank you!
It looks like CoreDataTutorialPart1.xcdatamodel (the model file containing the Event entity) was auto-generated by the Core Data Xcode template and isn't actually used anywhere in the project.

Add calendar to iphone

I am currently making and iphone app and a big function that i want to incorporate is the ability to subscribe to a calendar..
what i wish to do is to let the user give a URL for where the calendar is held, and from that url i want the app to fetch that calendar and subscribe to it..
i want to know how i can write the code to do this..
so in short my question is..
what code would i write to:
get .ics file from a URL
and save/subscribe to this newly
fetched .ics calendar file
any help and info would be very much appreciated..
The idea of "subscribing" to something isn't a build in function of the iOS SDK. To get this type of functionality would mean writing a recurring/timed function to grab the contents of this URL and process it locally.
The library I often use to simplify some of the HTTP functionality that you'll need is asi-http-request
https://github.com/pokeb/asi-http-request/tree
Hope this is helpful.