I am trying to show following HTML encoded form of string in UI.
ひょ䥜 姌祦橯ね褎 れずしゅぎゅ穃 ぢょ簨ゝじ氯 苯䛣蟤 覵だ盨ꤎ拣 夯ぢゃ焯埥榥 楎べ楚 坩づ, 覌びょ は䦞びぢじょ 氧へヴェ栤儦 ぢゅ大廩 ぷ諥 礊䛨にょ 襦綦卣楌䨵 が椧りゅ樃驌 蟥ゞ睥盥䨣 騌捯 驩ぎょちゅ レ゜㩟カグォ階 猪仯壪黨ザ れずしゅぎゅ穃, お䤂 ぴゅにゅ䧣鏨以 コざちゃ㠤ジョ 苨䰯お
Using this library, I wrote following code
#import "NSString+HTML.h"
NSLog(#"%#",plainText);
NSLog(#"%#",[plainText stringByDecodingHTMLEntities]);
On executing code, I am getting following exception:
-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x7bd4200
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'-[__NSCFString stringByDecodingHTMLEntities]: unrecognized selector sent to instance 0x7bd4200'
*** First throw call stack:
(0x1caa012 0x10e7e7e 0x1d354bd 0x1c99bbc 0x1c9994e 0xa72d 0x4a0e53f 0x4a20014 0x4a107d5 0x1c50af5 0x1c4ff44 0x1c4fe1b 0x1c047e3 0x1c04668 0x2bffc 0x237d 0x22a5 0x1)
libc++abi.dylib: terminate called throwing an exception
Note: I also tested my HTML encoded string on this link and found no errors in my string format.
#import "NSString+HTML.h"
NSLog(#"%#",plainText);
NSLog(#"%#",[plainText stringByDecodingHTMLEntities]);
You need add NSString+HTML.h, NSString+HTML.m, GTMNSString+HTML.h, GTMNSString+HTML.m file to your project
add -fno-objc-arc
Build Phases -> Compile Sources -> select GTMNSString+HTML.m -> double click right Compiler flags and add -fno-objc-arc
Things were perfectly fine. All I needed was just to add compile source flag -fno-objc-arc by double clicking NSString+HTML.m and GTMNSString+HTML.m under Compile Source tab.
Just imported NSString+HTML.m and no need to import other class
Drag and drop NSString+HTML.m and GTMNSString+HTML.m in Compile Source tab first before adding flag.
Related
I have a little function in a class:
/**
* #return float|int
*/
private function getPrice()
{
return rand(1000, 1000000) / 10;
}
In PhpStorm I am getting a warning by phpcs.
Missing function's return type declaration
But when I am running the phpcs from command line by:
phpcs --standard=PSR12 ./
I am getting no error message about this return type.
I've tried to search it in ruleset, but there is only a comment about this:
<!-- When you have a return type declaration present, there MUST be one space after the colon followed by the type declaration. The colon and declaration MUST be on the same line as the argument list cl
<!-- checked by PSR12.Functions.ReturnTypeDeclaration -->
But I did not see any rule for this.
Can somebody help me, how can I turn it on from the ruleset.xml or from command line?
Missing function's return type declaration is a PhpStorm inspection; it doesn't come from PHP_CodeSniffer, which doesn't have this feature yet.
I am trying to run a unit test in angular. But I am getting the below error message. It is not throwing during compilation process and my application works fine as expected but this error is thrown only when the unit testing is carried out.
Error message: Template parse error,Cant bind to ngxrow since it is not a known property of div. <div [ERROR ->]ngxcol="{{newwidth}}">
I am not sure if the error is due to assigning value using interpolation {{}}.Is there anyway I can fix this. Trying to find a solution for past 2 days
Below is my partial code:
component.html
<div ngxlayout="grid>
<div ngxrow>
<div ngxcol={{newwidth}}>
html core logic implemented
</div>
</div>
</div>
component.ts
export class AppComponent {
newwidth:any="30"
constructor(){}
}
I am not getting error if i directly assign the width as 30 in the ngxcol property directly but issue happens only if the value 30 is assigned using interpolation.
Well, such happens (sometimes/usually) when a developer forgets to import the module of library ( error message : Cant bind to ngxrow since it is not a known property of div - which means "angular doesn't know 'ngxrow' attribute of 'normal' HTMLDivElement, (so that means that, You probably using some library (which exports those directives 'ngxrow' ...)) he wishes to use (module, containing directives: ngxlayout, 'ngxrow' ...) ... when test being bootstraped (testBed creates module for test) -> You need to import the module too .. see as an example: https://github.com/ngx-dummy/accordion-simple/blob/master/projects/%40ngx-dummy/accordion-simple/src/lib/accordion-item.component.spec.ts#L33 )
I have a route (with Camel 2.23.1) like:
from("file://not.existing.dir?autoCreate=false&startingDirectoryMustExist=true&consumer.bridgeErrorHandler=true")
.onException(Exception.class)
.handled(true)
.log(LoggingLevel.ERROR, "...exception text...")
.end()
.log(LoggingLevel.INFO, "...process text...")
...
(I tried it with just &bridgeErrorHandler, too, since according to the latest doc the consumer. prefix seems to be not necessary any longer.)
According to the doc of startingDirectoryMustExist:
| startingDirectoryMustExist | [...] Will thrown an exception if the directory doesn’t exist. |
the following exception is thrown:
org.apache.camel.FailedToCreateRouteException: Failed to create route route1:
Route(route1)[[From[file://not.existing.dir?autoCreate=false...
because of Starting directory does not exist: not.existing.dir
...
but, despite of the doc and the description of [consumer.]bridgeErrorHandler it's propagated to the caller, i.e neither "exception text" nor "process text" are printed.
There is a unit test FileConsumerBridgeRouteExceptionHandlerTest that covers consumer.bridgeErrorHandler, so I think this works basically. Can it be that [consumer.]bridgeErrorHandler doesn't work in conjunction with the exception thrown by startingDirectoryMustExist?
Do I have to write my own [consumer.]exceptionHandler as mentioned in this answer to "Camel - Stop route when the consuming directory not exists"?
There also a post on the mailing list from 2014 that reports similar behaviour with startingDirectoryMustExist and consumer.bridgeErrorHandler.
UPDATE
After TRACEing and debugging through the code I found that the exception is propagated as follows:
FileEndpoint.createConsumer()
throw new FileNotFoundException(...);
--> RouteService.warmUp()
throw new FailedToCreateRouteException(...)
--> DefaultCamelContext.doStart()
(re)throw e
--> ServiceSupport.start()
(re)throw e
I couldn't find any point where bridgeErrorHandler comes into play.
Setting breakpoints on BridgeExceptionHandlerToErrorHandler's constructor and all of its handleException() methods doesn't stop at any of them.
Am I still missing something?
You should use the directoryMustExist option instead, then you can have the error during polling, which is where the bridge error handler can be triggered. The startingDirectoryMustExist option is checked during creating the consumer and therefore before the polling and where the bridge error handler operates.
See also the JIRA ticket: https://issues.apache.org/jira/browse/CAMEL-13174
I'm attempting to operate JDB programmatically. Unlike any sane debugger, JDB refers to the source code using class names instead of source file names. I'm assuming it's related to having the bytecode stored in multiple .class files instead of a single file(you would expect compilation with the -g flag to produce some reference to the source files, but making things easy is not the Java way...)
When JDB refers to classes I can usually do some string manipulations and look at the source file names to figure out which source file declares the relevant class. When I need to supply a class name for a breakpoint, I can read the file to get the package name, use the file name as the class name and generate the full class name that way. These two cases I got them working.
The problem starts with inner classes and anonymous classes. They reside in their own class files, and their names are mangled versions of the class that contains them. To set a breakpoint there I need the mangled name.
For example - this is Main.java(+line numbers):
1: public class Main{
2: public static void main(String[] args){
3: new Object(){
4: #Override public String toString(){
5: System.out.println("hi");
6: return "";
7: }
8: }.toString();
9: }
10:}
I compile it using javac -g Main.java and got Main.class and Main$1.class. I'm running jdb:
Initializing jdb ...
> stop on Main.main
Deferring breakpoint Main.main.
It will be set after the class is loaded.
> run Main
run Main
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started: Set deferred breakpoint Main.main
Breakpoint hit: "thread=main", Main.main(), line=3 bci=0
3 new Object(){
(I needed that part to load Main.class - otherwise I would simply get "It will be set after the class is loaded." for all the breakpoint setting attempts.)
If I set a breakpoint for line 8 it works properly:
main[1] stop at Main:8
Set breakpoint Main:8
If I set a breakpoint for line 5 - which is part of the anonymous class - I get an error:
main[1] stop at Main:5
Unable to set breakpoint Main:5 : No code at line 5 in Main
Line 5 clearly contains code - the problem is that the code is not compiled into Main.class - it's compiled into Main$1.class, so I need to write instead:
main[1] stop at Main$1:5
Deferring breakpoint Main$1:5.
It will be set after the class is loaded.
Now, the way Java splits the bytecode into .class files is deterministic, and in this simple example it's easy to figure out what goes where - when you examine it with human eyes - but I need a way to figure the mangled class names programmatically(with VimScript) for real world source files. Trying to syntactically analyze the source file and figure out which is what is too complex a task - there ought to be a simpler way.
Maybe extract that information from the .class files, or question JDB about it, or even make JDB use source file names like any sane debugger for any sane language...
I just had the same problem. As a quickfix I just grepped for the class name (Object in your case) in all the Main$[x].class.
If you find many of them you have to use the index of the order they appear in the source file.
I'd like to add an event handler in my C++ code.
I followed document in firebreath.org (Callback from Scripts):
FB::JSObjectPtr doc = m_host->getDOMDocument()->getJSObject();
doc->Invoke("addEventListener", FB::variant_list_of("load", FB::make_callback(this, &mine::foo)));
but seeing following error:
/home/dq/manager/mine.cpp: In member function ‘void mine::init()’:
/home/dq/manager/mine.cpp:284:119: error: no matching function for call to ‘variant_list_of(const char [5], FB::JSAPIPtr)’
/home/dq/manager/mine.cpp:284:119: note: candidates are:
/usr/include/firebreath/ScriptingCore/variant_list.h:122:5: note: FB::detail::VariantListInserter FB::variant_list_of(FB::variant)
/usr/include/firebreath/ScriptingCore/variant_list.h:122:5: note: candidate expects 1 argument, 2 provided
/usr/include/firebreath/ScriptingCore/variant_list.h:128:5: note: FB::VariantList FB::variant_list_of()
/usr/include/firebreath/ScriptingCore/variant_list.h:128:5: note: candidate expects 0 arguments, 2 provided
In file included from /home/deqing/manager/mine.h:51:0,
from /home/deqing/manager/mine.cpp:37:
/usr/include/firebreath/ScriptingCore/JSCallback.h: In function ‘FB::JSAPIPtr FB::make_callback(const T&, F, bool) [with T = mine*, F = void (mine::*)(), FB::JSAPIPtr = boost::shared_ptr<FB::JSAPI>]’:
/home/dq/manager/mine.cpp:284:118: instantiated from here
/usr/include/firebreath/ScriptingCore/JSCallback.h:47:107: error: request for member ‘get’ in ‘instance’, which is of non-class type ‘mine* const’
/usr/include/firebreath/ScriptingCore/JSCallback.h:49:97: error: request for member ‘get’ in ‘instance’, which is of non-class type ‘mine* const’
make[2]: *** [CMakeFiles/mine.dir/manager/mine.cpp.o] Error 1
make[1]: *** [CMakeFiles/mine.dir/all] Error 2
make: *** [all] Error 2
Looking into the implementation of make_callback(), I tried following instead:
FB::JSObjectPtr doc = m_host->getDOMDocument()->getJSObject();
doc->Invoke("addEventListener", FB::variant_list_of("load")(FB::JSAPIPtr(new FB::JSCallback(FB::make_method(this, &mine::foo)))));
Compile passed this time, but my function - mine::foo() is not called with document.load()
By using "Inspect Element" in chrome, in "Event Listeners" I can see a new listener is added for "load". However, the listenerBody is a <JSAPI-Auto Javascript Object>.
I'm afraid this is why mine::foo() is not called, Javascript don't know how to call it because it is not a function, only an object.
Any one know how to get this done?
Another way that I can think of is:
Register a custom event handler
Fire the custom event on init
I'd like to use something like:
registerEventMethod("myevent", &mine::foo);
so that when myevent is fired, mine::foo() can be called.
The question here is, mine::foo is not a JSObjectPtr, so this snippet of code wouldn't work.
What is the proper way to use registerEventMethod() in this case?
registerEventObject was really never intended to be called manually; it is used by the internal implementations of addEventListener and attachEvent. The purpose is to attach javascript handlers to events in the plugin.
I would recommend you use something like boost's signals and slots to implement your own c++-side event system; FireBreath's stuff was never intended to solve that problem. On the other hand, if you wanted to look at it it would probably be possible to extend FireBreath's functionality to support that and I have it on very good authority that the gatekeeper for FireBreath would probably entertain a pull request to that end. =]