stringWithContentsOfFile Deprecated - nsstring

I use the following code in my app, but it gives a warning that stringWithContentsOfFile is deprecated.
Can anyone tell me how to avoid this warning? Will this warning affect my app in the future?
NSString *myData= [NSString stringWithContentsOfFile:path];

Thought I might expand on daveoncode's answer a bit, so if you are not interested in the errors, you can just simply write
NSString *myData= [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
and it will work as you expected.

You have to use stringWithContentsOfFile:encoding:error: or stringWithContentsOfFile:usedEncoding:error:

Related

qDecimal library issue?

I started evaluating the qDecimal library, but I already encountered a baffling issue:
QDecDouble val(9.34);
val.add(QDecDouble(0.01));
qDebug() << val.toString();
outputs:
QDEBUG : UtilsTests::test() "9.340000000000000"
What am I doing wrong?
I can'f find anything with a fast search for QDecDouble... but I am almost sure that
val=val.add(QDecDouble(0.01));
would do the difference. The way you did it, the result did not saved somewhere...
Usually these commands returns the result that you want and you have to save it somewhere...

Autoit ImageSearch and Windows 7 Unterminated String

I just found ImageSearch library, very cool!
But when I tried to test it out I got strange errors, the only one I can't seem to get around is:
Line 46 (File "C:\...\ImageSearchDLL\ImageSearchTest.au3"):
U1A%a]A%01/4' Error: Unterminated String.
Thats the error but my script doesn't even have 46 lines so it must be in something its importing, here's the test script:
#include <MsgBoxConstants.au3>
#include "ImageSearchDLL.dll"
#include "ImageSearch.au3"
local $x, $y, $search
$search = _ImageSearch('search.bmp', 0, $x, $y, 0)
if $search = 1 then
mousemove($x,$y)
EndIf
MsgBox($MB_SYSTEMMODAL, "imagesearch", $x, 10)
its not line 46 in the imageSearch.au3 either.
So! my thinking is its a problem with the DLL.
I'm on windows 7, could it be that imagesearch.dll is not compatible with windows 7?
That would make me quite sad. Can someone help me? Perhaps there are newer alternatives I'm unaware of. Thanks so much!
You can not include .dll files on autoit. I don't know why you are using it.
The UDF calls it by itself.
The error must be on the version you are using. Just update it or look for a version more up to date.
Try to compile your script using x64 or x86 compiler, depending on your system. Then executing it using yourscript.exe
https://www.autoitscript.com/forum/topic/177190-imagesearch-gives-unterminated-string/
I found a "fixed" version that works with windows 7 here on the forums somewhere. attached is the file I found. I have no idea what was done to fix these unterminated string errors I kept getting but I must have been using a very old version or something. hope this helps others!

OpenCV + Qt + cv::mat::deallocate and cv::fastFree(void *) memory problems

I've got two error messages:
cv::mat::deallocate
cv::fastFree(void *)
While I was trying to compile my OpenCV and QT project. I am fighting with this problem for fifth day. Please guys if you know how I can solve this problem, write it here.
PS: I've uploaded an image.
http://postimg.org/image/wsyq8daf5/
After this day, my problem with the camera was totally solved.There are no more problems.Now i will continue my GUI project thanks to all of you guys.After 1-2 months i will start searching for how to write printer driver ;), but however.Thanks too all again. ;)
Finally i solved my problem using the QCamera class.Well guys, use QCamera, you don't need anything else to capture videos or images.Read everything about it and bye bye ;)

Xcode 4: Temporarily removing lines of code you might want to put back

I am new to programming with no formal programming training, so please excuse this newbie question. I can't seem to find a definitive answer on it, and need to be sure.
Here's the scenario: sometimes I need to try different lines of code to see if they work, but still want to keep the original lines in there in case the new lines don't work (or for future reference). I thought by putting // in front of the line I want to "comment out" would mean the line of code would be ignored when compiling the program, but my app crashed and pointed to a line I thought was commented out. I am using Xcode 4.
Is there another symbol I should be using to comment out lines or blocks of code? For example, will /* at the beginning and */ at the end accomplish this?
For "commenting out" big blocks of code, I do conditionals like:
#if I_AM_TESTING_SO_DONT_COMPILE_THIS
...
...
...
...
#endif // I_AM_TESTING_SO_DONT_COMPILE_THIS
And yes, the traditional C-style /* and */ also work to "comment out" blocks of code.
The reason your compile crashed with // is because while a single line gets commented out, you might have had some extra code on a second line.
Such as:
//NSString * someContentFromSomewhere = [[NSString alloc] initWithContentsOfURL:
[NSURL URLWithString: #"http://www.stackoverflow.com"]];
The first line is commented out. The second line is a syntax error.
Also, make sure you do a clean build. It's possible that sometimes old object files are used and even though you commented out a line in the IDE, it may not have build with that updated file.

Where is keywords code assist and letter not allowed problem(Aptana Studio 3)

I recently switched from Aptana2 to version3.0.3, and the first thing i did was to install the sdomcl. file to get jQuery code assist.It works fine for jQuery, but there is no code assist for many keywords.For exymple there is no support for var,while,throw,try,break,case,catch etc.
Also there is no function, instead intellisense sugests Function.
The second problem is that i am constantly getting this warning '<' + '/' +letter not allowed here when typing something valid like this:
confirmDiv =$("")-sorry for this,but it wont let me type what i want, basically i am just creating a new div with the correct syntax.
Could it be something with Html Tidy?Anyways, big thanks in advance!
Aptana Studio 3.0.4 includes code assist for JavaScript keywords.
I've read that for Javascript the slashes / must be escaped with backslashes \ as it says here
Doing so the warning dissapears ;)

Resources