Can I inspect a Core Data model from Xcode? - xcode

Can I inspect a Core Data model from Xcode?
I want to see if the data are correctly stored into the database.

You can use this tool http://christian-kienle.de/CoreDataEditor
You can inspect all datas from your persistent store

There's no direct "show me some data stored at some path I specified somewhere in my code or at runtime that happens to use this model" feature.
If you want to view a file easily in Xcode, you'll need to add the file to your project (don't let it copy into project - just reference it in place) so you can select it in the navigator.
Caveat: This only works for text-based store types (like XML or some custom text-based store type you cooked up). If you use binary or SQLite store types, all you'll see is binary. There's no SQLite database browsing/editing functions in Xcode.

I have not come across a way to check the Core Data Modal directly from Xcode... right now I use "SQlite Database Browser" to check my database... its a good way to check your data in the database.. you can also execute queries on it...
P.S. If you do come across a way to check the Core Data Modal directly from Xcode, please do post it as an answer here...

Related

Is there a way to get table contents from 3rd party UWP application?

There is UWP application which has a table with data and no built-in way to export it anyhow.
Is there a way to "spy" on the window to at least get raw text content of the table, or all text of whole window?
Can WinAPI be used here, I wonder? Even the most "perverted" way will do.
EDIT: To clarify,
acceptable case: to get table contents "manually" as temporary measure;
desired case: to get table contents from within my own application.
If you just need a tool to see the UI contents, Windows SDK Inspect.exe could help you.
https://msdn.microsoft.com/en-us/library/dd318521(v=vs.85).aspx
If you want to write a program to interact with UI contents, use the Windows UIAutomation library. https://msdn.microsoft.com/en-us/library/windows/desktop/ee684009(v=vs.85).aspx. Previous url also shows some info on UIAutomation.

NSDocument for relational data / todo list?

I want to create an OS X app where users can edit items from something similar to a todo list - each item has text, status (done/todo), creation date and some other data. The items of the todo list have also relationship with other entities.
I created an iOS app for this which uses a core data data model... Now I want to make an OS X app and sync.
I'm new to OS X development and just stumbled upon NSDocument, and wondered if this could be usable. I just want that the user sees the list similar to an excel table and can edit it. I found some examples to store only a string e.g. https://developer.apple.com/library/mac/documentation/DataManagement/Conceptual/DocBasedAppProgrammingGuideForOSX/ManagingLifecycle/ManagingLifecycle.html or this tutorial http://www.raywenderlich.com/12779/icloud-and-uidocument-beyond-the-basics-part-1
There's also NSPersistentDocument to work with core data, which I think is what I would have to try out.
But generally speaking, does it have any benefit to use NSDocument for my todo list? One could be the undo functionality but I'm not sure if this is applicable. Any advices?
I'm also not sure if I have to use one document for each todo or rather load them all in one document, and if this works correctly with table view... Maybe in a todo app I will never get hundreds of entries, but principally I could. Would I be able to paginate, etc.?
Thanks!
Edit: I just read Document-based application, or not? specially "The key question is one of independence. If all of the objects in your application's model are related then there's no need to manage independent documents." Not sure how to apply this to my model... It's relational. Some 1:1 and 1:n relationships. Does this mean that all my objects are related? Or can I still treat them as "independent" documents...?
If the app has just one todo list, there's no benefit to using NSDocument. Use Core Data, and you'll get undo support without having to use NSDocument.
NSDocument would help if your app lets people create multiple todo lists and save each list in its own file. NSDocument is designed for apps like word processors and spreadsheets where people can create multiple documents and have multiple documents open at once. If you were to use NSDocument for this app, each todo list would be its own document.
UPDATE
The main benefits of NSDocument involve the File menu. When you use NSDocument, choosing File > New creates a new document. Choosing File > Open opens an Open File dialog for you to load a document from disk. Choosing File > Save when you save a new document opens a Save File dialog for you to save the document as a file on disk.
When determining whether or not to use NSDocument, ask yourself the following questions: Do you want the user to create a new todo list by choosing File > New? Do you want the user to save the todo list as a separate file by choosing File > Save? Do you want the user to open todo lists by choosing File > Open? If the answer to these questions is YES, NSDocument will help you. If the answer to these questions is NO, NSDocument won't help you. Also, NSDocument will not help you when dealing with the "other documents" that reference the individual todos in the lists.
To answer your question about iOS syncing, are you using UIManagedDocument in your iOS app? If so, you can use NSPersistentDocument in your Mac app and share the same Core Data model. If not, you won't be able to use NSPersistentDocument. You'll have to use NSManagedObject in your Mac app to use the same Core Data model in both the iOS and Mac apps. It's possible to use NSDocument and Core Data together without using NSPersistentDocument, but I don't know how to use them together. But if you are not using UIManagedDocument in your iOS app, that is a sign that you should not use NSDocument in your Mac app.

Spotlight importer: how to hide the actual file name?

I have a Mac shoebox app with a custom data format. I'd like to add Spotlight support.
From what I read, the recommendation seems to be to define a custom UTI file type and create one file of that type for each "record" in my app as a reference to the actual "record" that my app can then make sense of when the user clicks on a search result.
So far so good. My custom Spotlight importer works and indexes my "reference" files. They show up in Spotlight.
However, the file name reveals that this is my custom "reference" file. From a user's perspective that does not make sense.
Is there a way to hide or replace what is shown as file name and path in Spotlight?
Also, if a users presses Command while clicking on the search result, the file is revealed in Finder. In my case in the Library/Caches/Metadata/MyApp folder. That's not what I want… I don't want users to see this folder, because it reveals internals about the app.
EDIT:
In a way, my app is similar to a Core Data app with a database, only that I'm using a custom data format. With Core Data, the user also does not see the actual database file.
Try providing a value for kMDItemDisplayName

VS 2010 Extension Access Loaded Types

I am currently try to write a code generator and I would like the user to select the target type for a property on a class via a drop down, but to populate the drop down I need to know what types are available to the project.
How do I access via a VS extension the properties that have been loaded by the current project?
Check out my answer here:
How to access project code meta data?
You should be able to get the types from the code snippet I provided.

Why does previously saved data not appear in opened document of Core Data app?

I have created the Core Data app that is outlined in this tutorial by Apple using XCode 4. All works fine however when I save the document and reopen it the document window is empty and no data is shown.
When I check the data file, I can actually see the saved data in the file (only for XML format as other formats are unreadable). This problem rises for all of the supported save formats (XML, binary and SQLLITE).
There are no stacktraces in the debugger. All looks fine...
Found it. You need to check the "Prepares content" checkbox on the controller (attributes inspector pane of the Array Controller) otherwise data is not shown.

Resources