Core Data - NSURL command and momd - core-data

I'm working on a project that uses Core Data and I can't seem to find an adequate explanation of why the following line of code in my program always returns NIL for modelURL.
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:#"CoreDataBooks" withExtension:#"momd"];
This example is straight out of Apple's sample code and it actually works in their program, but I can't get it to work in mine.
Questions:
1) Does something have to be in place before I try to implement. I notice the Apple solution has a "CoreDataBooks.DCBStore" file that I do not have. I've tried a number of things to create this...No luck.
2) momd: I've read a lot about this and it seems it's quite a bit different than "mom." I understand the "d" gives the dataset additional capabilities and in some answers posted here, the author indicated to use "mom" and not "momd" without a great explanation of why. All the same, this doesn't work either.
As always, I appreciate your help!
Glenn

So -[NSBundle URLForResource:…] is returning nil. That's supposed to mean the requested resource doesn't exist.
Fire up the Finder and have a look inside the bundle. Confirm that file really doesn't exist. Is there actually a momd file (or similar) there, but by a different name? Probably want to adjust your code to match.
If no such files exist, you probably need to add your Core Data model to your build target.

Related

Sketch Plugin - NSFileManager contentsOfDirectoryAtPath - not a function

I'm trying to make a plugin for Sketch that allows me to automate the production of multilingual assets.
Right now, I select a list of languages files that kick off the process. I use NSOpen Panel to select these. For each language file, it makes a new page for that language, and finds text layers with a special tag and replaces the copy with the translated copy.
While it's doing this, I'd like it to check to see if there are any screenshots in another folder screenshots/lang, and store a list of the filepaths for those images. This is where I'm getting stuck at the moment.
Currently I have:
var screenShotPaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:mySourcePath error:NULL];
When I try to run my Plugin in sketch in its current state, the console is saying:
(Sketch Plugin)[6547]: TypeError: fileManager.contentsOfDirectoryAtPath_ is not a function.
(In 'fileManager.contentsOfDirectoryAtPath_( mySourcePath)', 'fileManager.contentsOfDirectoryAtPath_' is undefined)
I've tried looking all over I see a lot of issues where the list isn't coming back,coming back null, etc, but I can't find anything where contentsOfDirectoryAtPath is coming back as not a function.
Is this because it's a plugin getting run by an application and navigating the filesystem is a security issue?
Any help would be much appreciated. Thank you!
A little late to the game here, but hopefully someone searching for this will find this useful.
I found that you have to use the full method: contentsOfDirectoryAtURL_includingPropertiesForKeys_options_error(url,nil,nil,nil);
I'm more familiar with JS so I'm using js syntax. Hopefully someone else can translate this to Cocoa.
Works for me: (Sketch 55)
var fileManager = [NSFileManager defaultManager];
var paths = [fileManager contentsOfDirectoryAtPath:filePath error:null];

Sphinx4 figuring out correct models

I am trying to use the Sphinx4 library for speech recognition, but I cannot seem to figure out the correct combination of acoustic model-dictionary-language model. I have tried out various combinations and I get a different error every time.
I am trying to follow the tutorial on http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4. I do not have a config.xml as I would if I was using ConfigurationManager instead of Configuration, because there is no perceivable way of passing the location of the config file to the Configuration itself (ConfigMgr takes it as an argument to the constructor); and that might be my problem right there. I just do not know how to point to one, and since the tutorial says "It is possible to configure low-level components of the application through XML file although you should do that ONLY IF you understand what is going on.", I assume having a config.xml file is not compulsory.
Combining the latest dictionary (7b - obtained from Sourceforge) with the latest acoustic model (cmusphinx-en-us-5.2.tar.gz - from SF again) and the language model (cmusphinx-5.0-en-us.lm.gz - from SF again) results in NullPointerException in startRecognition. The issue is similar to the problem here: sphinx-4 NullPointerException at startRecognition, but the link given in the answer no longer works. I obtained 0.7a from SF (since that is the dict the link seems to point at), but I am getting even earlier in the execution Error loading word: ;;; when I use that one. I tried downloading latest models and dict from the Github repo, that results in java.lang.IndexOutOfBoundsException: Index: 16128, Size: 16128.
Any help is much appreciated!
You need to use latest code from github
http://github.com/cmusphinx/sphinx4
as described by tutorial
http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4
Correct models (en-us) are already included, you should not replace anything. You should not configure any XML files, use samples as provided in the sources.

Having problems decompiling class files

I have been working on a game for a while now and i tried to make this game as easy to understand as possible and easy to change as well by using one variable in a few places and not write the variables value in each place so that if i decide to change the value i wont have to change it every where, i will just have to change the value of the variable.
Two days ago i formatted my computer and saved in my external Hard Drive a .Jar file of the
game and the Eclipse(Coding environment) folder in where i THOUGHT the game source should be located at but it wasn't thus losing my source code.
I was very upset but then I remembered that you can decompile a jar file.
I searched for a decompiler and found the jd gui decompiler opened my jar file and i was happy
to see that its actually works but then... I noticed that the code is alliiiiitle bit different.
The compiler added tons of this. all the classes which doesn't matter to me.
Then i noticed that every where there was a double type number it added a .0 and a D
at the end of the number and even is some places where i had for example 0.7 i saw that there is 0.699999996 which again doesn't really matter, not a big deal.
But then i noticed that in all the places where i had a final variable it changed it to its value (Example : supposed to be : numRowsToDraw = Panel.WIDTH / tileHeight + 2;
what it is now : numRowsToDraw = 768 / tileHeight + 2;)
which ruined all the easy to change aspect of the program and i didn't want to change
the numbers back to the variable in all the places there should be a variable because it will take a lot of work.
So my question is : Is there a decompiler which doesn't change your code?
If there is can you tell me the name of it?
THANKS!
Oh and i forgot to mention that i tried afterwards the JAD decompiler which did the same thing...
No, there is not. Decompilation can never get back source level constructs like comments or the particular formatting of literals. But I'm sure there are automated source formatting tools out there that let you do stuff like remove Ds on double literals.

Base folder in directory structure

So I'm fairly new to UNIX (This might be basic but I couldn't find a good answer) and I'm trying to run some code I got from the web. In the README it says:
"If you put these 3rd-party packages in a pathUtils folder in the same base
folder as the shadowDetection, they should be picked up automatically by
setPath. "
Does this mean I need to create a pathUtils folder in the same directory as shadowDetection? So it would look like:
/path/shadowDetection
/path/pathUtils
or would it look like
/path/shadowDetection/pathUtils
Your help and understanding is greatly appreciated.
This ReadMe you're referencing (from https://github.com/jflalonde/shadowDetection) is unclear, since it's not clear whether "shadowDetection" refers to the shadowDetection folder, or the shadowDetection software. If it's the former, then your first example (pathUtils alongside shadowDetection folder) would make sense; if it's the latter, then your second example (pathUtils inside shadowDetection folder) would apply.
My guess is that the author means parallels so I'd try it your first way first, but since it's ambiguously worded, try it the other way if it doesn't work. Once you figure it out, email the author and suggest he clarify his ReadMe.

Getting echofunc.vim to work

I came across echofunc.vim today (from a link in SO). Since I'm rubbish at remembering the order of function parameters, it looked like a very useful tool for me.
But the documentation is a bit lean on installation! And I've not been able to find any supplementary resources on the internet.
I'm trying to get it running on a RHEL box. I've copied the script into ~/.vim/plugin/echofunc.vim however no prompt when I type in a function name followed by '('. I've tried adding
let g:EchoFuncLangsUsed = ["php","java","cpp"]
to my .vimrc - still no prompting.
I'm guessing it needs to read from a dictionary somewhere - although there is a file in /usr/share/vim/vim70/ftplugin/php.vim, this is the RH default and does not include an explicit function list.
I'm not too bothered about getting hints on the functions/methods I've defined - just trying to get hints for the built-in functions. I can see there is a dictionary file available here which appears to provide the resources required for echofunc.vim, I can't see how I set this up.
TIA,
It expects a tags file, the last line of the description describes exactly how to generate it:
ctags -R --fields=+lS .
It works here with PHP but not with JS. Your mileage may vary.
I didn't know about this plugin, thanks for the info.
You should try phpcomplete.vim, it shows a prototype of the current function in a scratchpad. It is PHP only, though.

Resources