I have a CFUserNotificationDisplayAlert setup like this:
CFOptionFlags cfRes;
CFUserNotificationDisplayAlert(5, kCFUserNotificationNoteAlertLevel,
NULL, NULL, NULL,
CFSTR("Okay"),
CFSTR("Stop!"),
&cfRes);
switch (cfRes)
{
case kCFUserNotificationDefaultResponse:
strTest = CFSTR("Default response");
break;
case kCFUserNotificationAlternateResponse:
strTest = CFSTR("Alternate response");
break;
}
With this code I get this error:
use of undeclared identifier kCFUserNotifactationDefualtResponce (And the other kCF*'s)
Any ideas? I have the following imported:
#import <CoreFoundation/CoreFoundation.h>
#import <CoreData/CoreData.h>
#import <UIKit/UIKit.h>
The CFUserNotification API is not available on iOS. Looks to me like you copied that bit of code from a Mac App.
Quoted from CodaFi's comment above so question can be marked as answered as per: https://meta.stackexchange.com/questions/54718/how-should-i-handle-questions-which-are-answered-in-the-comments
Related
I'm writing a mapping template for an AWS API Gateway integration response to return a custom error output format.
My function looks like this:
{
"gw_code":"$gw_code",
"er_code":"$er_code",
"code":"$gw_code" + "-" + "$er_code",
"developerMessage":"$developerMessage"
"message":"$message"
"gw_msg":"$code
$developerMessage"
}
#set ($er_num = "200")
#set ($er_msg = "ACCESS_DENIED")
#if($code == "403-001" && $developerMessage == "Unauthorized")
// Ignore
#else
{
"code" : "403-001",
"developerMessage" : "Unauthorized."
}
#end
But the URL prints an internal server error as the output:
{"message": "Internal server error"}
I re-read the VTL documentation guide and attempted to modify the code by boiling it down to this:
#set($messageOverride = "foo")
{
#if($status == "403-001" && $developerMessage = "Unauthorized")
// Ignore
#else
#if($inputRoot.toString().contains("error"))
"code" : "403-001",
"developerMessage" : "Unauthorized."
#end
#end
#end
}
But the internal server error is still showing up and I can't figure out what I'm doing wrong.
Your second code is a big improvement from the first, however it still needs some work.
Your function should look something like this:
#set($inputRoot = $input.path('$'))
#if($status == "403-001" && $developerMessage = <TBD>)
// Ignore
#else
#if($inputRoot.toString().contains("error"))
#set($context.responseOverride.status = 403)
#set($context.requestOverride.header.devMessage = $message1Override)
#end
#end
#end
I haven't tested it, but in theory, it should work.
I am trying to use LogglyLogger-CocoaLumberjack in my swift project.
I am getting this error in xCode.
Enum case 'verbose' has no associated values
I am unable to resolve this.
https://prnt.sc/uznr01
I am actually trying to translate the Objective-C code in swift 5. Here is my swift function
in appDelegate.swift class
func initLoggly(){
// static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
let ddLogLevel:DDLogLevel = .verbose
// LogglyLogger *logglyLogger = [[LogglyLogger alloc] init];
let logglyLogger = LogglyLogger()
// [logglyLogger setLogFormatter:[[LogglyFormatter alloc] init]];
logglyLogger.logFormatter = LogglyFormatter()
// logglyLogger.logglyKey = #"your-loggly-api-key";
logglyLogger.logglyKey = "XXXXXXXXXXXX-XXXXXX"
//
// // Set posting interval every 15 seconds, just for testing this out, but the default value of 600 seconds is better in apps
// // that normally don't access the network very often. When the user suspends the app, the logs will always be posted.
// logglyLogger.saveInterval = 15;
logglyLogger.saveInterval = 15
// [DDLog addLogger:logglyLogger];
DDLog.add(logglyLogger)
// // Do some logging
// DDLogVerbose(#"{\"myJsonKey\":\"some verbose json value\"}");
// ddLogLevel.verbose("{\"initloggly\":\"some verbose json value\"}") // also tried this, error ==> Enum case 'verbose' cannot be used as an instance member
DDLogLevel.verbose("{\"initloggly\":\"some verbose json value\"}") // Here is the error on this line
}
Please point out what I am doing wrong!
This library is heavly based on C preprocessor macros which aren't accessible from Swift.
You will probably need to write a small set of wrapper functions in Objective-C that use these macros and are in turn callable from Swift.
Here's an example of how this could look like:
LogglyWrapper.h:
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#interface LogglyWrapper : NSObject
+(void) logVerbose:(NSString*) msg;
#end
NS_ASSUME_NONNULL_END
and LogglyWrapper.m:
#import "LogglyWrapper.h"
#import <LogglyLogger.h>
#implementation LogglyWrapper
static const DDLogLevel ddLogLevel = DDLogLevelVerbose;
+(void) logVerbose:(NSString*) msg {
DDLogVerbose(#"%#", msg);
}
#end
usage from Swift:
LogglyWrapper.logVerbose("foo")
I know what duplicate symbol linker error means, but in my case I don't know how I'm getting it. I have the following file, which defines some simple globals
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
BOOL useTestCode = YES;
#endif
Then I import it in two *.m files, and use the global.
// someFile1.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
// someFile2.m
#import "defines.h"
- (void)foo
{
if (useTestCode) {
NSLog(#"Using test code");
}
else {
NSLog(#"NOT Using test code");
}
}
If I comment out one of the #import "defines.h" statement in either file, I don't get the duplicate symbol linker error, but of course the corresponding *.m file will fail to compile. Why am I getting the duplicate symbol linker error? How do I solve it in iOS 7?
Here is the linker error message. It's literally for the simple code above.
duplicate symbol _useTestCode in:
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile2.o
/Users/cfouts/Library/Developer/Xcode/DerivedData/DupSymbol-bnfownlxdoyqelbhxzpyaaitfshy/Build/Intermediates/DupSymbol.build/Debug-iphonesimulator/DupSymbol.build/Objects-normal/x86_64/DSsomeFile1.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
in your header you have
BOOL useTestCode = YES;
which is copied to every .m file that includes it so you have multiple useTestCode symbols
you need to change the header to contain
extern BOOL useTestCode;
and in one .m file, define the variable
BOOL useTestCode = YES;
Though Bryan C's answer is one solution, and it gave me a clue, I like this better.
// defines.h
#ifndef _DEFINES_H
#define _DEFINES_H
static BOOL useTestCode = YES;
#endif
I am trying to implement my first phonegap plugin (version 2.3) on iOS - but the call of the native function seems not to work.
My plugin is based on this introduction:
http://docs.phonegap.com/en/2.3.0/guide_plugin-development_ios_index.md.html#Developing%20a%20Plugin%20on%20iOS
So I added to the plugins-section of config.xml:
<plugin name="Echo" value="Echo" />
my calling javascript:
$(document).ready (function (){
$('#testBtn').submit(function () {
alert("test");
var param = ["a", false];
cordova.exec(
function(winParam) { alert("ok"); },
function(err) { alert("error"); },
"Echo", "echo", param);
return false;
});
}
(the alert in the first row gets called by pushing my testBtn, so the rest should also be executed...)
In my plugins-directory:
Echo.h:
#import <Cordova/CDV.h>
#interface Echo : CDVPlugin
- (void)echo:(CDVInvokedUrlCommand*)command;
#end
Echo.m:
#import "Echo.h"
#implementation Echo
- (void)echo:(CDVInvokedUrlCommand*)command
{
NSLog(#"echo!");
}
#end
The echo-Function in Echo.m never gets called ... can anyone tell me why? I don't get any error messages - just nothing happens...
I was struggling in this step like you. then I Called that javascript function after device getting ready. Problem has solved. Now, Its working fine...
I'm busy with a library of a collegae. In his code he sets isa a few times. This stills works but is officially deprecated. The alternative should be the object_setClass function. But when I replace it I get a warning: Implicit declaration of function 'object_setClass' is invalid in C99.
Perhaps i am missing an import or something? Anyone an idea? Thanks.
if(nodePtr->type == XML_ELEMENT_NODE)
{
self->isa = [DDXMLElement class];
//object_setClass(self, [DDXMLElement class]);
}
else if(nodePtr->type == XML_DOCUMENT_NODE)
{
self->isa = [DDXMLDocument class];
//object_setClass(self, [DDXMLDocument class]);
}
It's declared in #include <objc/runtime.h> -- have you included that header?