Why am I getting EXC_BAD_ACCESS error when converting to a float or a double? (In Swift) - nsstring

I am trying to store some values from textfields as doubles and floats and I cannot get past the above error.
I have defined the property to match the attribute in my cordata database:
#NSManaged var custjobcost: Double
When I am mapping the properties in order to save them, I am using the following code, but it will not accept it - on runtime, I get the error indicated above.
newItem.custjobcost = (textfield.text as NSString).doubleValue
I have also the same thing, but with float and floatvalue instead.

Try this
newItem.custjobcost = textfield.text.bridgeToObjectiveC().doubleValue

Related

Flow type for an array of HTML elements?

I'm converting some working JavaScript code to Flow. I have a variable IMAGES which is created but not immediately assigned any value. Later on it becomes an array of HTML elements.
Why is this code wrong?
let IMAGES Array<HTMLElement>;
// Later on within an init function:
IMAGES = Array.from(document.querySelectorAll(`.${someImagesClass}`));
The Flow error I get is:
Parsing error: Unexpected token, expected ";"
All I was missing was the :
let IMAGES: Array<HTMLElement>;
There is no generic-syntax and no need to "publish" a variable in JavaScript! Just merge both:
// Later on within an init function:
let IMAGES = Array.from(document.querySelectorAll(`.${someImagesClass}`));

Qt: how to save QTextEdit contents with custom properties

I have a text editor (QTextEdit). Some words in my editor contains additional information attached (namely, two corresponding integer positions in wave file for that word).
They are stored in Python object as custom properties for QTextCharFormat objects (I attach them with code like this: self.editor.textCursor().setCharFormat(QTextCharFormat().setProperty(MyPropertyID, myWordAttachment) )
Unfortunately, if I save my document to html, all of that additional formatting is lost.
So, I want to perform simplest task: to save my document with all of it's formatting,including myWordAttachment (and to load it from disk).
Am I right that Qt5 doesn't have something ready for it, and I have to write all that document's serialization code by myself? (I still hope that where is simple function that did the job)
1.you loop your text every character.
2.and you catch the character and its charFormat()
3.and you get the properties.
4.Because the properties are eventually a value of something, int,str,...
So you get the properties by charFormat().property(1),(2),(3)... or properties()
5.The most important thing is the character's position & the range.You get the position during the 1th loop.
6.When you catch the CharFormats, you insert into something hashable object like list.
& and you don't forget to insert the CharFormats position.
6.you save your document and the position & properties.
My suggestion for your solution.
1.you can get characterCount() by the QTextDocument object.
2.you loop the range of the characterCount()
3.Before doing it, you make a QTextCursor object.
4.you set the textcursor at the first position.(movePosition method & Start moveoperation & KeepAnchor flag)
5.you move the cursor to right one character & Another.
6.you check the character's charFormat() by tc.charFormat() and the tc.position()
7.But it is the time to Think twice. CharFormat is always the bunch of characters.
you probably get some characters of the same CharFormat().
You can prepare for it.I can Think about some way,but... you should set the QCharFormat objectType or propertyId() for specifing the QCharFormat in Advance(during editing your document).Why don't you set the texts into the properties for after saving & loading.I hope you manage to pass here during debugging & tring.
8.if you get a charFormat,and you check the objectType().
9.if the objectType() is the same as Before searched, you pass the search engine without doing anything.
10.The second important thing is that calls clearSelection() each searching.
11.You save your document() as it is html strings.and you save the charFormats() properties.
12.when you load your document(),the html sentence comes back.
and load the properties.
you make QTextCursor and setPosition( the property's position saved in advance.)
you move QTextCursor until the position and you select the target texts.
you adopt the charFormat properties again and the end.
Summary
The important thing how you specify the charFormat().
You can catch the charFormat without any problem.but the charFormat() is adopted in some range.So you must distinguish the range.
1.The targeted texts is set in the QTextCharFormat's property.
2.You have The QTextCursor pass during the same QTextCharFormat's object.
I can Think of them...
I Think it is some helps for you.

premake5 adding new complex fields

I am trying to add a new premake5 field in my premake5 script but am having trouble understanding how to specify the field.kind .
I want to add a field that contains a list of (path, string ) pairs but can't work out how to specify the kind spec .
The documentation and examples are not particularly clear.
This is how I have registered my new field
premake.api.register( {
name = "mypathmappings",
scope = "config",
kind = "list:path:string", or "list:keyed:path:string"
}
)
and inside of a config scope I declare the field item like so
project myproject
mypathmappings { ["path/to/file1"] = "stringvalue1", ["path/to/file2"] = "stringvalue2"}
However when it comes to processing time I don't get what I'm expecting in the field:
function processpathmappings(cfg)
local pathmappings = cfg.mypathmappings
for path, value in pairs(pathmappings) do
--do something with the path and value but
--value is not a string as expected
end
end
Can someone explain how the complex kinds can be built up correctly from the field kinds registered in api.lua?
I get that "list:integer" specifies a list of integers but don't know how the "keyed" element works for example.
Right now, it is not possible to control the "kind" of the keys in a keyed value. The best you will be able to get with the current system is kind="keyed:string", which should give you the values (the strings) that you want, but the paths will not be processed by Premake (made absolute, etc.)
If it is feasible, you might want to flip it around to kind="keyed:path" and set the values like this:
mypathmappings { ["stringvalue1"] = "path/to/file1" }
But that relies on your string values being unique within a map.
In theory, Premake's field API could be extended to support kinds of keys; feel free to open a ticket or submit a pull request.

Trying to figure out what this line of code means

This code is from a program I use to enter and track information. Numbers are entered as work orders (WO) to track clients. But one of the tables is duplicating the WO information. So I was trying to figure out a general outline of what this code is saying so that the problem can be fixed.
Here is the original line:
wc.dll?x3~emproc~datarecord~&ACTION=DISPLAY&TABLE+WORK&KEYVALUE=<%work.wo%&KEYFIELD=WO
What I think I understand of it so far, and I could be very wrong, is:
wc.dll?x3~emproc~datarecord~&ACTION
//No clue because don't know ~ means or using & (connects?Action)
=DISPLAY&TABLE+WORK&KEYVALUE
//Display of contents(what makes it pretty) and the value inside the table at that slot
=<work.wo%&KEYFIELD
//Calling the work from the WO object
=WO
//is Assigning whatever was placed into the WO field into the left side of the statement
I'll do my best to interpret the statement, with the limited information you've provided:
wc.dll is an instruction to invoke a DLL
? is introducing a list of parameters (like a query string in HTTP)
x3~emproc~datarecord~ seems like a reference to a function in the dll
& parameter separator
ACTION=DISPLAY set the ACTION parameter to the value DISPLAY
TABLE+WORK perhaps sets a couple of flags
KEYVALUE=<%work.wo% set the KEYVALUE parameter to the value of <%work.wo%
KEYFIELD=WO set the KEYFIELD parameter to the value WO
Hope that helps.

Retrieve explicit values from document library

I'm trying to pull some fields from my Document Library. Right now, I can retrieve these 2 fields to return the correct values, in my success function.
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
alert(oListItem.get_item('Title'));
alert(oListItem.get_item('UserField1'));
}
But when I try to call a computed field, such as 'NameOrTitle' oListItem.get_item('NameOrTitle')); I get IE telling me the property or field has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.
This value has content inside it right now. And I need it, as it's displaying the file name. How can I get this field? I have looked elsewhere and I have read stuff about doing:
context.load(allItems, 'Include(NameOrTitle)');
Then in my succeess function, I do oListItem.get_nameOrTitle(). Is this correct?
Well I do that and now I'm getting
Object doesn't support property or method 'get_nameOrTitle'
Please help. Thanks.
oListItem.get_item('FileRef');
Will get me the url

Resources