broderboy + stackoverflow   239

MySQL Join Where Not Exists
I have a MySQL query that joins two tables

Voters

Households

they join on voters.household_id and household.id

Now what i need to do is to modify it where the voter table is joined to a third table called elimination, along voter.id and elimination.voter_id, how ever the catch is that i want to exclude any records in the voter table that have a corresponding record in the elimination table. how do i craft a query to do this?

this is my current query

SELECT `voter`.`ID`, `voter`.`Last_Name`, `voter`.`First_Name`,

`voter`.`Middle_Name`, `voter`.`Age`, `voter`.`Sex`,

`voter`.`Party`, `voter`.`Demo`, `voter`.`PV`,

`household`.`Address`, `household`.`City`, `household`.`Zip`

FROM (`voter`)

JOIN `household` ON `voter`.`House_ID`=`household`.`id`

WHERE `CT` = '5'

AND `Precnum` = 'CTY3'

AND `Last_Name` LIKE '%Cumbee%'

AND `First_Name` LIKE '%John%'

ORDER BY `Last_Name` ASC

LIMIT 30
stackoverflow 
6 days ago by broderboy
Send JSON data via POST (ajax) and receive json response from Controller (MVC)
I created a function in javascript like that:

function addNewManufacturer() {

var name = $("#id-manuf-name").val();

var address = $("#id-manuf-address").val();

var phone = $("#id-manuf-phone").val();

var sendInfo = {

Name: name,

Address: address,

Phone: phone

};

$.ajax({

type: "POST",

url: "/Home/Add",

dataType: "json",

success: function (msg) {

if (msg) {

alert("Somebody" + name + " was added in list !");

location.reload(true);

} else {

alert("Cannot add to list !");

}

},

data: sendInfo

});

}

I called jquery.json-2.3.min.js script file and I used it for toJSON(array) method.

In controller, I have this Add action

[HttpPost]

public ActionResult Add(PersonSheets sendInfo) {

bool success = _addSomethingInList.AddNewSomething( sendInfo );

return this.Json( new {

msg = success

});

}

But sendInfo as method parameter becomes null.

The model:

public struct PersonSheets

{

public int Id;

public string Name;

public string Address;

public string Phone;

}

public class PersonModel

{

private List<PersonSheets> _list;

public PersonModel() {

_list= GetFakeData();

}

public bool AddNewSomething(PersonSheets info) {

if ( (info as object) == null ) {

throw new ArgumentException( "Person list cannot be empty", "info" );

}

PersonSheets item= new PersonSheets();

item.Id = GetMaximumIdValueFromList( _list) + 1;

item.Name = info.Name;

item.Address = info.Address;

item.Phone = info.Phone;

_list.Add(item);

return true;

}

}

How could I do in action method when the data was sent with POST ?

I don't know how to use.

Also, it is possible to send back the response (to ajax) via JSON ?

Thank you
stackoverflow 
8 days ago by broderboy
How do I set adaptive multiline UILabel text?
I have a UILabel named titleLabel in my storyboard nib set to its default height. I want it to programatically expand in height to fit it's content. Here is what I have tried so far:

// just setting content

titleLabel.text = "You don't always know what you are getting with mass-market cloud computing services. But with SimpliCompute, the picture is clear. SimpliCompute gives you powerful virtual servers you can deploy using just your web browser. That’s enterprise grade technology you can deploy and control on-the-fly."

titleLabel.numberOfLines = 0

titleLabel.preferredMaxLayoutWidth = 700

titleLabel.lineBreakMode = NSLineBreakMode.ByWordWrapping

titleLabel.sizeToFit()

None of this works for me in any combination! I always only see one line of text in my UILabel . What am I doing wrong?

I absolutely need the text content to be variable.
stackoverflow 
14 days ago by broderboy
How to connect UIView outlets to a custom subview
I'm still new to xcode / iOS and have the following problem:

in order to display some mobile debug information, I have a UIview added/connected as outlet-property to one of my Viewcontroller. This view is a custom subclass of UIview. Now I addeddd some UIlabels as sub views to this view and want to drag the outlet connections from these labels to my customUIview.h file in order to have these labels accessible as properties of my custom UIview class (no need to access them directly from the view Controller).

Problem is that the interface builder (I'm using Storyboards/ xcode4.3) does not make the trick. I can connect the outlets to the ViewControllerClass.h but not to my sub view's .h file.

Can anyone point out where the problem is?
stackoverflow 
15 days ago by broderboy
Get first item from Split()
I use the SPLIT function to split a string which looks something like 1.23/1.15 .

Right now it yields two cells, as it should. But how do I get a certain element from the result? I would like to do something like this:

SPLIT("1.23/1.15", "/")[0]

to extract 1.23 . What is the correct syntax for that?

I tried using the INDEX function, without success: =INDEX(SPLIT("1.23/1.15", "/"), 0,0)
stackoverflow 
19 days ago by broderboy
Canvas in Google Chrome 61.0.3163.79 are too slow on Linux
I recently updated Google Chrome to the 61.0.3163.79 version and it was suddenly very slow with canvas. This issue only appears on Linux.

For exemple, http://vincentgarreau.com/particles.js/ was 60 FPS before the Chrome update, and now it run at 2 FPS.

What's wrong with the new Google Chrome update ?

P.S: Chromium 61.0.3163.79 works fine on my computer.
stackoverflow 
27 days ago by broderboy
Using ls to list directories and their total sizes
Is it possible to use ls in Unix to list the total size of a sub-directory and all its contents as opposed to the usual 4K that (I assume) is just the directory file itself? I.E.

total 12K

drwxrwxr-x 6 *** *** 4.0K 2009-06-19 10:10 branches

drwxrwxr-x 13 *** *** 4.0K 2009-06-19 10:52 tags

drwxrwxr-x 16 *** *** 4.0K 2009-06-19 10:02 trunk

After scouring the man pages I'm coming up empty.
stackoverflow 
4 weeks ago by broderboy
Laravel pluck fields from relations
I have a Seller object which has a related User. I need to fill a select from LaravelCollective so I need to make something like this:

{!! Form::selectGroup('seller_id', 'Seller', Seller::with('user')->pluck('user.first_name', 'id')->toArray(), null) !!}

The problem is that I cannot take fields from relationships (user.first_name).

How can I do it?

UPDATE

I want to avoid doing this...

<?php

$sellers = [];

Seller::with('user')->get()->each(function ($seller) use (&$sellers) {

$sellers[$seller->id] = $seller->user->first_name;

});

?>
stackoverflow 
5 weeks ago by broderboy
How can I disable ARC for a single file in a project?
I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option.

Is this possible? How do I disable ARC on a per-file basis?
stackoverflow 
6 weeks ago by broderboy
Using usort in php with a class private function
ok using usort with a function is not so complicated

This is what i had before in my linear code

function merchantSort($a,$b){

return ....// stuff;

}

$array = array('..','..','..');

to sort i simply do

usort($array,"merchantSort");

Now we are upgrading the code and removing all global functions and putting them in their appropriate place. Now all the code is in a class and i can't figure out how to use the usort function to sort the array with the parameter that is an object method instead of a simple function

class ClassName {

...

private function merchantSort($a,$b) {

return ...// the sort

}

public function doSomeWork() {

...

$array = $this->someThingThatReturnAnArray();

usort($array,'$this->merchantSort'); // ??? this is the part i can't figure out

...

}

}

The question is how do i call an object method inside the usort() function
stackoverflow 
6 weeks ago by broderboy
How can I simulate app being killed in background?
I'm trying to verify that my app (App1) behaves correctly when it is shut down by the system after it launches another app (App2). Is there any way to simulate or force this behavior?

Telling the simulator to simulate a memory warning while App2 is running doesn't do anything until App1 is brought back to the foreground. Would killing App1 from the debugger simulate the same sequence of app events?

EDIT: My app is placed in the background when it launches a second app to handle a file. This second app then relaunches my app, and I'm trying to verify that my app behaves correctly when the system has shut it down while the second app is executing.
stackoverflow 
7 weeks ago by broderboy
Difference between two dates in MySQL
How to calculate the difference between two dates, in the format YYYY-MM-DD hh: mm: ss and to get the result in seconds or milliseconds?
stackoverflow 
8 weeks ago by broderboy
How to remove unused dependencies from composer?
I installed a package with composer, and it installed many other packages as dependencies.

Now I uninstalled the main package with composer remove packageauthor/packagename , but all the old dependencies were not removed. I expected composer to clean up and only keep packages that are required according to composer.json and their dependencies.

How can I force composer to clean up and remove all unused packages ?
stackoverflow 
8 weeks ago by broderboy
How to use generic protocol as a variable type
Let's say I have a protocol :

public protocol Printable {

typealias T

func Print(val:T)

}

And here is the implementation

class Printer<T> : Printable {

func Print(val: T) {

println(val)

}

}

My expectation was that I must be able to use Printable variable to print values like this :

let p:Printable = Printer<Int>()

p.Print(67)

Compiler is complaining with this error :

"protocol 'Printable' can only be used as a generic constraint because

it has Self or associated type requirements"

Am I doing something wrong ? Anyway to fix this ?

**EDIT :** Adding similar code that works in C#

public interface IPrintable<T>

{

void Print(T val);

}

public class Printer<T> : IPrintable<T>

{

public void Print(T val)

{

Console.WriteLine(val);

}

}

//.... inside Main

.....

IPrintable<int> p = new Printer<int>();

p.Print(67)

EDIT 2: Real world example of what I want. Note that this will not compile, but presents what I want to achieve.

protocol Printable

{

func Print()

}

protocol CollectionType<T where T:Printable> : SequenceType

{

.....

/// here goes implementation

.....

}

public class Collection<T where T:Printable> : CollectionType<T>

{

......

}

let col:CollectionType<Int> = SomeFunctiionThatReturnsIntCollection()

for item in col {

item.Print()

}
stackoverflow 
9 weeks ago by broderboy
Checking if an instance's class implements an interface?
Given a class instance, is it possible to determine if it implements a particular interface? As far as I know, there isn't a built-in function to do this directly. What options do I have (if any)?
stackoverflow 
9 weeks ago by broderboy
How do I position one image on top of another in HTML?
I'm a beginner at rails programming, attempting to show many images on a page. Some images are to lay on top of others. To make it simple, say I want a blue square, with a red square in the upper right corner of the blue square (but not tight in the corner). I am trying to avoid compositing (with ImageMagick and similar) due to performance issues.

I just want to position overlapping images relative to one another.

As a more difficult example, imagine an odometer placed inside a larger image. For six digits, I would need to composite a million different images, or do it all on the fly, where all that is needed is to place the six images on top of the other one.
stackoverflow 
10 weeks ago by broderboy
How can I delete all Git branches which have been merged?
I have many Git branches. How do I delete branches which have already been merged? Is there an easy way to delete them all instead of deleting them one by one?
stackoverflow 
11 weeks ago by broderboy
NSUserDefaults and KVO issues
I'm using NSUserDefaults in my app and I would like to be notified when a particular value is changed. For that, I added the following lines in viewDidLoad:

NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];

[settings synchronize];

[settings addObserver:self forKeyPath:@"pref_server" options:NSKeyValueObservingOptionNew context:NULL];

And the method to be notified:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

{

NSLog(@"Change");

NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];

if (object == settings && [keyPath isEqualToString:@"pref_server"])

{

NSLog(@"Server did change");

}

}

Unfortunately, the latter is never called...@"pref_server" is the item identifier I have set in Root.plist, in Settings.bundle. What am I doing wrong?
stackoverflow 
12 weeks ago by broderboy
Regular expression to extract text between square brackets
Simple regex question. I have a string on the following format:

this is a [sample] string with [some] special words. [another one]

What is the regular expression to extract the words within the square brackets, ie.

sample

some

another one

Note: In my use case, brackets cannot be nested.
stackoverflow 
12 weeks ago by broderboy
Display blob (.pdf) in an angular app
I have been trying to display pdf file which I am getting as a blob from a $http.post response. The pdf must be displayed within the app using <embed src> for example.

I came across a couple of stack posts but somehow my example doesn't seem to work.

JS:

According to this doc , I went on and tried...

$http.post('/postUrlHere',{myParams}).success(function (response) {

var file = new Blob([response], {type: 'application/pdf'});

var fileURL = URL.createObjectURL(file);

$scope.content = fileURL;

});

Now from what I understand, fileURL creates a temporary URL that the blog can use as a reference.

HTML:

<embed src="" width="200" height="200"></embed>

I am not sure how to handle this in Angular, the ideal situation would be to (1) assign it to a scope, (2) 'prepare/rebuild' the blob to a pdf (3) pass it to the HTML using <embed> because I want to display it within the app.

I have been researching for more than a day now but somehow I can't seem to understand how this works in Angular... And let's just assume the pdf viewer libraries out there weren't an option.
stackoverflow 
march 2018 by broderboy
Add AddThis to React component
I have a blog implementation based on ReactJS that I would like to integrate with AddThis. I have my social icons and I want to use them. So I'm looking for a way to integrate just the AddThis backend service.

I tried looking around but I was not able to find how to integrate AddThis to a ReactJS component.

I saw this somewhere and it uses a special namespace which to the best of my knowledge is not react friendly.

<div addthis:url='blog_url' addthis:title='blog_title' class="addthis_toolbox">

<a class="addthis_button_facebook">

<svg ... />

</a>

<a class="addthis_button_twitter">

<svg ... />

</a>

<a class="addthis_button_linkedin">

<svg ... />

</a>

<a class="addthis_button_reddit">

<svg ... />

</a>

</div>

<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4fc9383e1ee05f1b"></script>

Also, I saw this JSFiddle with some information on it, but it is not using ReactJS and does not use custom icons.

Question : Is there any good documentation around AddThis + React?
stackoverflow 
march 2018 by broderboy
How do I correctly clone a JavaScript object?
I have an object, x . I'd like to copy it as object y , such that changes to y do not modify x . I realized that copying objects derived from built-in JavaScript objects will result in extra, unwanted properties. This isn't a problem, since I'm copying one of my own, literal-constructed objects.

How do I correctly clone a JavaScript object?
stackoverflow 
march 2018 by broderboy
React intellisense in Visual Studio Code
I'm sure I'm missing something simple, but I simply can't get React.js IntelliSense to work in Visual Studio code.

I have done the following:

npm install typings

ext install Typings Installer in Visual Studio Code

ext install Typings in Visual Studio Code

typings init in the root directory of my "app"

typings install --ambient react-global in the root of my "app"

restarted Visual Studio Code

That's created a typings folder. My app is structured in the following folder structure:

├───public

│ ├───css

│ └───scripts

| └───test.js

└───typings

├───browser

│ └───ambient

│ └───react-global

└───main

└───ambient

└───react-global

Yet when I'm in test.js and type React. I get no IntelliSense.

I presume I'm missing something fundamental?

EDIT: Thanks for your help, it's actually more involved again. I think I have it working and wrote about my steps here http://mattdufeu.co.uk/setup-intellisense-vscode-react-js/
stackoverflow 
march 2018 by broderboy
What does the ">" (greater-than sign) CSS selector mean?
For example:

div > p.some_class {

/* Some declarations */

}

What exactly does the > sign mean?
stackoverflow 
march 2018 by broderboy
Removing MySQL 5.7 Completely
I am trying to uninstall mysql from my ubuntu 12.04 completely. But not able to.

I tried a lot of commands. But nothing is working. Can anyone help out here!

sudo apt-get remove mysql-server mysql-client mysql-common

sudo apt-get autoremove

I am not able to understand what to do.

I want to remove everything regarding MySQL. Whenever I am trying to locate it. I am getting that.

I want everything to be removed. mysql-server, mysql-client, mysql-libraries and even configuration.

Please help me!!!
stackoverflow 
march 2018 by broderboy
How to pass "Null" (a real surname!) to a SOAP web service in ActionScript 3?
We have an employee whose last name is Null. Our employee lookup application is killed when that last name is used as the search term (which happens to be quite often now). The error received (thanks Fiddler!) is:

<soapenv:Fault>

<faultcode>soapenv:Server.userException</faultcode>

<faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.MissingArgumentException : The SEARCHSTRING parameter to the getFacultyNames function is required but was not passed in.]</faultstring>

Cute, huh?

The parameter type is string .

I am using:

WSDL (SOAP)

Flex 3.5

ActionScript 3

ColdFusion 8

Note that the error does not occur when calling the webservice as an object from a ColdFusion page.
stackoverflow 
february 2018 by broderboy
How to protect "master" in github?
I have a few contributors in my github project. I want to allow only one of them to "push" to master. And this guy is not me (the owner of the repository). Is it possible to do?
stackoverflow 
february 2018 by broderboy
Get class name of object as string in Swift
Getting the classname of an object as string using

object_getClassName(myViewController)

returns something like this

_TtC5AppName22CalendarViewController

I am looking for the pure version: "CalendarViewController". How do I get a cleaned up string of the class name?

I found some attempts of questions about this but not an actual answer. Is it not possible?
stackoverflow 
february 2018 by broderboy
Regex matching beginning AND end strings
This seems like it should be trivial, but I'm not so good with regular expressions, and this doesn't seem to be easy to Google.

I need a regex that starts with the string 'dbo.' and ends with the string '_fn'

So far as I am concerned, I don't care what characters are in between these two strings, so long as the beginning and end are correct.

This is to match functions in a SQL server database.

For example:

dbo.functionName_fn - Match

dbo._fn_functionName - No Match

dbo.functionName_fn_blah - No Match
stackoverflow 
february 2018 by broderboy
NSCharacterSet: How do I add "_" to alphanumericCharacterSet text restriction?
Building an NSCharacter set to restrict a UITextField for entering user names. I want the user to be able to also enter an underscore (so [A-Za-z0-9_]) but alphanumericCharacterSet does not include it. Is there a way to specify a range like that in short form? I see + (id)characterSetWithRange:(NSRange)aRange , but I'm not really understanding how that would work.

I've got a simple UITextField sub-class that I pass the character set to. The restriction works fine and doesn't allow the user to enter anything but alpha numeric. Just need to add the "_" to those allowances.

NSCharacterSet *characterSet = [NSCharacterSet alphanumericCharacterSet];

[textField setAllowed:characterSet];

[textField setFrame:frame];
stackoverflow 
february 2018 by broderboy
UIActivityViewController customize text based on selected activity
I want to customize text for the same information but when I am sharing it on Facebook I don't want to use the twitter hash tags or @username scheme...

How can I diversify text for sharing based on which sharing service would be used?

Ofcourse I'm using UIActivityViewController:

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[shareText, shareURL] applicationActivities:nil];
stackoverflow 
february 2018 by broderboy
Removing MySQL 5.5 Completely
I am trying to uninstall mysql from my ubuntu 12.04 completely. But not able to.

I tried a lot of commands. But nothing is working. Can anyone help out here!

sudo apt-get remove mysql-server mysql-client mysql-common

sudo apt-get autoremove

I am not able to understand what to do.

I want to remove everything regarding MySQL. Whenever I am trying to locate it. I am getting that.

I want everything to be removed. mysql-server, mysql-client, mysql-libraries and even configuration.

Please help me!!!
stackoverflow 
february 2018 by broderboy
for each loop in objective c for accessing NSMutable dictionary
I am finding some difficulty in accessing mutable dictionary keys and values in Objective-C.

Suppose I have this:

NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init];

I can set keys and values. Now, I just want to access each key and value, but I don't know the number of keys set.

In PHP it is very easy, something as follows:

foreach ($xyz as $key => $value)

How is it possible in Objective-C?
stackoverflow 
january 2018 by broderboy
UIActivityViewController UIActivityViewControllerCompletionWithItemsHandler
List item

Using Swift for an app that runs in iOS 8, I need to write a completion handler for the UIActivityViewController to capture the results of which "share" method a user selected.

This is a snippet of the code I have so far. My question is how to I set the avc.completionWithItemsHandler ? I'm sure it's simple, but I don't see it.

var activityItems = NSMutableArray()

activityItems.addObject("Email or text for 'share' goes here")

var avc = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)

avc.setValue("Subject for Email", forKey: "Subject")

avc.completionWithItemsHandler = //Here is where I dont know what to do.

self.navigationController?.presentViewController(avc, animated: true, completion: nil)
stackoverflow 
january 2018 by broderboy
How to temporarily disable a foreign key constraint in MySQL?
Is it possible to temporarily disable constraints in MySQL?

I have two Django models, each with a ForeignKey to the other one. Deleting instances of a model returns an error because of the ForeignKey constraint:

cursor.execute("DELETE FROM myapp_item WHERE n = %s", n)

transaction.commit_unless_managed() #a foreign key constraint fails here

cursor.execute("DELETE FROM myapp_style WHERE n = %s", n)

transaction.commit_unless_managed()

Is it possible to temporarily disable constraints and delete anyway?
stackoverflow 
january 2018 by broderboy
How can iOS7 untethered energy/network recordings be accessed?
iOS7 has a preference under " Preferences | Developer | Instruments / Logging | Untethered Recording" to record the energy and network usage data.

How do I extract this from the device to view in Xcode or Instruments?
stackoverflow 
january 2018 by broderboy
The application bundle does not contain a valid identifier
I try to run my project but i get the following error "The application bundle does not contain a valid identifier."

here my info.plist

I followed other answer on the question. I don't have any "Ressources" folder inside my project.

Thanks for your help
stackoverflow 
january 2018 by broderboy
KissXML not returning strings
I have an example XML like this:

<rss version="2.0">

<channel>

<title></title>

<link></link>

<description></description>

<item>

<title></title>

<link></link>

<description></description>

<pubDate></pubDate>

<guid></guid>

</item>

and so on… And my obj-c syntax is looking like this:

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

DDXMLDocument *ddDoc = [[DDXMLDocument alloc] initWithData:data options:0 error:&error];

NSArray *xmlItems = [ddDoc nodesForXPath:@"//item" error:&error]; // where ddDoc is your DDXMLDocument

NSMutableArray *returnArray = [[NSMutableArray alloc] initWithCapacity:[xmlItems count]];

for(DDXMLElement* itemElement in xmlItems)

{

ActiveActivity *activity = [[ActiveActivity alloc] init];

NSString *itemValueAsString = [[itemElement attributeForName:@"link"]stringValue];

[returnArray addObject:activity];

}

It's returning no value, can anyone say me why?
stackoverflow 
december 2017 by broderboy
How to configure Travis-CI to build pull requests & merges to master w/o redundancy
To put it in "BDD" terms:

Background:

Given I'm contributing to a GH repo

When I create a pull request

Then Travis should build the latest commit

When I push to an existing pull request

Then Travis should build the latest commit

When I merge a pull request to master

Then Travis should build master

I was confused by Travis-CI's "build pushes" and "build PRs" settings, as:

Enabling both causes each Pull Request to be build twice by Travis

once for the commit on that branch

and once again for the merge commit of that branch into its destination

Enabling just "build PRs" causes PRs to be built, but doesn't result in post-merge builds (i.e. on master).

Enabling "pushes" brute-force satisfies the above criteria by building all pushes to the repo. You can try to finagle things by white- & black-listing branches, but that will probably bite you unless you're rigorously disciplined with branch names.

This is explained more in Travis-CI docs and GH issue #3241 .

Anyone know a configuration that satisfies the above criteria?
stackoverflow 
december 2017 by broderboy
SecItemAdd and SecItemCopyMatching returns error code -34018 (errSecMissingEntitlement)
Sometimes when I run an application on device from Xcode I would try to access the keychain but fail due to error -34018. This doesn't match any of the documented keychain error codes and can't be consistently reproduced. (happens maybe 30% of the time, and it's not clear to me why it happens). What makes debugging this problem very difficult is the total lack of documentation. Any idea what causes this and how to fix it? I'm using Xcode 5 and running iOS 7.0.4 on device.

There is an open issue about this here: https://github.com/soffes/sskeychain/issues/52

EDIT: Adding keychain access code per request

I'm using the SSKeychain library for interfacing with keychain. Here's the snippet.

#define SERVICE @"default"

@implementation SSKeychain (EXT)

+ (void)setValue:(NSString *)value forKey:(NSString *)key {

NSError *error = nil;

BOOL success = NO;

if (value) {

success = [self setPassword:value forService:SERVICE account:key error:&error];

} else {

success = [self deletePasswordForService:SERVICE account:key error:&error];

}

NSAssert(success, @"Unable to set keychain value %@ for key %@ error %@", value, key, error);

if (!success) {

LogError(@"Unable to set value to keychain %@", error);

}

LogTrace(@"Will set keychain account %@. is to nil? %d", key, value == nil);

if (value == nil)

LogWarn(@"Setting keychain %@ to nil!!!", key);

}

+ (NSString *)valueForKey:(NSString *)key {

NSError *error = nil;

NSString *value = [self passwordForService:SERVICE account:key error:&error];

if (error && error.code != errSecItemNotFound) {

NSAssert(!error, @"Unable to retrieve keychain value for key %@ error %@", key, error);

LogError(@"Unable to retrieve keychain value for key %@ error %@", key, error);

}

return value;

}

+ (BOOL)removeAllValues {

LogInfo(@"Completely Reseting Keychain");

return [[self accountsForService:SERVICE] all:^BOOL(NSDictionary *accountInfo) {

return [self deletePasswordForService:SERVICE account:accountInfo[@"acct"]];

}];

}

@end

Vast majority of the time it's just fine. Sometimes I'll hit the assertion failures where I'm unable to either write to or read from keychain, causing critical assertion failure.
stackoverflow 
november 2017 by broderboy
Properly Create and Serve PDF Blob via HTML5 File and URL APIs
Ok, Let's say I have document data stored somewhere, let's arbitrarily take this pdf .

Issue #1. What I want to do is make an AJAX call to this URL (because I need to pass some authentication headers and it is cross domain). Then take the returned data, create a blob url for it, append an iFrame to the DOM, and direct the src to the blob url.

Currently my code looks like this:

$.ajax({

url:'http://www.grida.no/climate/ipcc_tar/wg1/pdf/tar-01.pdf'

}).done(function(data){

var file = new Blob([data], {type:'application/pdf'}),

url = URL.createObjectURL(file),

_iFrame = document.createElement('iframe');

_iFrame.setAttribute('src', url);

_iFrame.setAttribute('style', 'visibility:hidden;');

$('#someDiv').append(_iFrame);

});

Unfortunately, I am getting a 'Failed to Render PDF' in the iFrame.

Issue #2. I'd like this to result in a file download prompt. Not sure how to guarantee this given that PDF's will naturally just display in the iFrame.
stackoverflow 
november 2017 by broderboy
How can I use mySQL replace() to replace strings in multiple records?
We have a database that has a bunch of records with some bad data in one column, in which an embedded editor escaped some stuff that shouldn't have been escaped and it's breaking generated links.

I want to run a query to replace the bad characters in all the records, but can't figure out how to do it. I found the replace() function in MySQL, but how can I use it inside a query?

For example, what would be the correct syntax if I wanted to replace the string &lt; with an actual less-than angle bracket (< ) in all records that have &lt; in the articleItem column? Can it be done in a single query (i.e. select and replace all in one swoop), or do I have to do multiple queries? Even if it's multiple queries, how do I use replace() to do the replace on the value of a field on more than one record?
stackoverflow 
november 2017 by broderboy
How do you create a "reverse pivot" in Google Sheets?
I am trying to produce a "reverse pivot" function. I have searched long and hard for such a function, but cannot find one that is already out there.

I have a summary table with anywhere upto 20 columns and hundreds of row, however I would like to convert it into a flat list so I can import to a database (or even use the flat data to create more pivot tables from!)

So, I have data in this format:

Summary Table http://www.joietrade.co.uk/summary.png

And need to convert it to this format:

Summary Table http://www.joietrade.co.uk/list.png

I have created a function that will read the range from sheet1 and append the re-formatted rows at the bottom of the same sheet, however I am trying to get it working so I can have the function on sheet2 that will read the whole range from sheet1.

No matter what I try, I can't seem to get it to work, and was wondering if anybody could give me any pointers?

Here is what I have so far:

function readRows() {

var sheet = SpreadsheetApp.getActiveSheet();

var rows = sheet.getDataRange();

var numRows = rows.getNumRows();

var values = rows.getValues();

heads = values[0]

for (var i = 1; i <= numRows - 1; i++) {

for (var j = 1; j <= values[0].length - 1; j++) {

var row = [values[i][0], values[0][j], values[i][j]];

sheet.appendRow(row)

}

}

};
stackoverflow 
november 2017 by broderboy
swift case falling through
Does swift have fall through statement? e.g if I do the following

var testVar = "hello"

var result = 0

switch(testVal)

{

case "one":

result = 1

case "two":

result = 1

default:

result = 3

}

is it possible to have the same code executed for case "one" and case "two"?
stackoverflow 
november 2017 by broderboy
Convert string to DATE type in swift 3
I have this structure:

struct message {

var id: String = "0"

var text: String = ""

var date: Date!

var status: String = ""

}

I have to load this structure from dbase, that it export in String format also 'date'.

So I write this code to convert String to Date type:

let dateFormatter = DateFormatter()

dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"

dateFormatter.timeZone = NSTimeZone(abbreviation: "UTC") as TimeZone!

let dataDate = dateFormatter.date(from: elemMessage["date"] as! String)!

And I load it in structure:

message(id: elemMessage["id"] as! String, text: elemMessage["text"] as! String, date: dataDate as! Date, status: elemMessage["status"] as! String)

But I have this warning: "Cast from 'Date' to unrelated type 'Date' always fails"

So if I run app it will fails.

How Can I fix this, the 'date' var in structure have to be Date type.

Thank you.
stackoverflow 
november 2017 by broderboy
throwing an exception in objective-c/cocoa
What's the best way to throw an exception in objective-c/cocoa?
stackoverflow 
november 2017 by broderboy
Add badge to app icon in iOS 8 with Swift
I'd like to set a badge on the icon of my app like in apple's mail app (number on top of the icon).

How can I do this in Swift (iOS8)?
stackoverflow 
november 2017 by broderboy
How to implement re-ordering of CoreData records?
I am using CoreData for my iPhone app, but CoreData doesn't provide an automatic way of allowing you to reorder the records. I thought of using another column to store the order info, but using contiguous numbers for ordering index has a problem. if I am dealing with lots of data, reordering a record potentially involves updating a lot of records on the ordering info (it's sorta like changing the order of an array element)

What's the best way to implement an efficient ordering scheme?
stackoverflow 
november 2017 by broderboy
Disable UITextField Predictive Text
With the release of iOS 8 I would like to disable the predictive text section of the keyboard when I begin typing in a UITextField. Not sure how this is done, any help would be appreciated!
stackoverflow 
october 2017 by broderboy
Xcode process launch failed: Security
I have been developing an app for 1 or 2 weeks now and just yesterday I have updated my iPhone 5S to the iOS 8 GM. Everything worked fine and I could test on my device as well until I deleted the app from my phone and wanted to build again. The following error appeared:

Could not launch "My App"

process launch failed: Security

When I test with the simulator it works fine.

Is this because of the iOS 8 GM update and how can I fix this launch problem?

I want to be able to test on my iPhone and in the simulator.
stackoverflow 
october 2017 by broderboy
How to use break or continue with Laravel Eloquent Collection's each method?
How to use break or continue with Laravel Eloquent Collection's each method.

My code is this:

$objectives->each(function($objective) {

Collection::make($objective)->each(function($action) {

Collection::make($action)->each(function($success_indicator) {

Collection::make($success_indicator)->each(function($success_indicator) {

echo 'hi';

continue;

});

});

});

});
stackoverflow 
october 2017 by broderboy
Can I embed a custom font in an iPhone application?
This question relates to iOS pre-3.2. As of 3.2 this functionality is easily achievable using samvermette's answer below, and I have changed the Accepted Answer (from commanda to samvermette) to reflect this. I can't give credit to both answers (besides upvotes) but they are both good.

I would like to have an app include a custom font for rendering text, load it, and then use it with standard UIKit elements like UILabel . Is this possible?

I found these links:

http://discussions.apple.com/thread.jspa?messageID=8304744

http://forums.macrumors.com/showthread.php?t=569311

but these would require me to render each glyph myself, which is a bit too much like hard work, especially for multi-line text.

I've also found posts that say straight out that it's not possible, but without justification, so I'm looking for a definitive answer.

EDIT - failed -[UIFont fontWithName:size:] experiment

I downloaded Harrowprint.tff (downloaded from here ) and added it to my Resources directory and to the project. I then tried this code:

UIFont* font = [UIFont fontWithName:@"Harrowprint" size:20];

which resulted in an exception being thrown. Looking at the TTF file in Finder confirmed that the font name was Harrowprint.

EDIT - there have been a number of replies so far which tell me to read the documentation on X or Y. I've experimented extensively with all of these, and got nowhere. In one case, X turned out to be relevant only on OS X, not on iPhone. Consequently I am setting a bounty for this question, and I will award the bounty to the first person who provides an answer (using only documented APIs) who responds with sufficient information to get this working on the device. Working on the simulator too would be a bonus.

EDIT - It appears that the bounty auto-awards to the answer with the highest number of votes. Interesting. No one actually provided an answer that solved the question as asked - the solution that involves coding your own UILabel subclass doesn't support word-wrap, which is an essential feature for me - though I guess I could extend it to do so.
stackoverflow 
october 2017 by broderboy
UIFont fontWithName returns nil
In my info.plist, I added a key "Fonts provided by application" and added EdwardianScriptITCStd.otf

But, when I try to get that font, it returns nil:

NSLog(@"%@", [UIFont fontWithName:@"EdwardianScriptITCStd"

size:16.0f]);

I printed the font families using [UIFont familyNames] and it's not there either:

(

Thonburi,

"Snell Roundhand",

"Academy Engraved LET",

"Marker Felt",

"Geeza Pro",

"Arial Rounded MT Bold",

"Trebuchet MS",

Arial,

Marion,

"Gurmukhi MN",

"Malayalam Sangam MN",

"Bradley Hand",

"Kannada Sangam MN",

"Bodoni 72 Oldstyle",

Cochin,

"Sinhala Sangam MN",

"Hiragino Kaku Gothic ProN",

Papyrus,

Verdana,

"Zapf Dingbats",

Courier,

"Hoefler Text",

"Euphemia UCAS",

Helvetica,

"Hiragino Mincho ProN",

"Bodoni Ornaments",

"Apple Color Emoji",

Optima,

"Gujarati Sangam MN",

"Devanagari Sangam MN",

"Times New Roman",

Kailasa,

"Telugu Sangam MN",

"Heiti SC",

"Apple SD Gothic Neo",

Futura,

"Bodoni 72",

Baskerville,

"Chalkboard SE",

"Heiti TC",

Copperplate,

"Party LET",

"American Typewriter",

"Bangla Sangam MN",

Noteworthy,

Zapfino,

"Tamil Sangam MN",

"DB LCD Temp",

"Arial Hebrew",

Chalkduster,

Georgia,

"Helvetica Neue",

"Gill Sans",

Palatino,

"Courier New",

"Oriya Sangam MN",

Didot,

"Bodoni 72 Smallcaps"

)

What am I missing?

Thanks!
stackoverflow 
october 2017 by broderboy
Why are there 2 ways to unstage a file in git?
Sometimes git suggests git rm --cached to unstage a file, sometimes git reset HEAD file . When should I use which?

EDIT:

D:\code\gt2>git init

Initialized empty Git repository in D:/code/gt2/.git/

D:\code\gt2>touch a

D:\code\gt2>git status

# On branch master

#

# Initial commit

#

# Untracked files:

# (use "git add <file>..." to include in what will be committed)

#

# a

nothing added to commit but untracked files present (use "git add" to track)

D:\code\gt2>git add a

D:\code\gt2>git status

# On branch master

#

# Initial commit

#

# Changes to be committed:

# (use "git rm --cached <file>..." to unstage)

#

# new file: a

#

D:\code\gt2>git commit -m a

[master (root-commit) c271e05] a

0 files changed, 0 insertions(+), 0 deletions(-)

create mode 100644 a

D:\code\gt2>touch b

D:\code\gt2>git status

# On branch master

# Untracked files:

# (use "git add <file>..." to include in what will be committed)

#

# b

nothing added to commit but untracked files present (use "git add" to track)

D:\code\gt2>git add b

D:\code\gt2>git status

# On branch master

# Changes to be committed:

# (use "git reset HEAD <file>..." to unstage)

#

# new file: b

#
stackoverflow 
september 2017 by broderboy
How to disable json output from specific ansible commands?
Some ansible commands produce json output that's barely readable for humans. It distracts people when they need to check if playbook executed correctly and causes confusion.

Example commands are shell and replace - they generate a lot of useless noise. How can I prevent this? Simple ok | changed | failed is enough. I don't need the whole JSON.
stackoverflow 
september 2017 by broderboy
Run R script from command line
I have a file, called a.r , it has a chmod of 755,

sayHello <- function(){

print('hello')

}

sayHello()

How can I run this via command-line?
stackoverflow 
september 2017 by broderboy
How do I make my debug app version receive production push notifications on iOS?
My server is sporting only one version of sending push notifications, and it has my production (release) push certificate.

How do I test the notifications on my debug device and debug builds, using the same production certificate?

My device is sending the token, but when I attempt to send a real push notification Apple servers return status 8 error, that means that device token is incorrect.
stackoverflow 
september 2017 by broderboy
dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib
I get this error after adding a Swift class to an old Xcode project.

dyld: Library not loaded: @rpath/libswift_stdlib_core.dylib

How can I make the project run again?
stackoverflow 
september 2017 by broderboy
OpenUrl freezes app for over 10 seconds
I'm currently developing an App, that needs to open a browser to display a webpage.

To do that i use the [UIApplication sharedApplication] openURL method with an url.

In iOS 6 this works perfectly, but in iOS 7 it freezes the app for 10+ seconds, then opens the browser and all is good.

This happens using ad hoc provisioning. Someone on the internet commented that this was a known problem, however, that one comment was all i could find regarding this problem.
stackoverflow 
august 2017 by broderboy
How to override trait function and call it from the overridden function?
Scenario:

trait A {

function calc($v) {

return $v+1;

}

}

class MyClass {

use A;

function calc($v) {

$v++;

return A::calc($v);

}

}

print (new MyClass())->calc(2); // should print 4

This code doesn't work, and I cannot find a way to call a trait function like it was inherited. I tried calling self::calc($v) , static::calc($v) , parent::calc($v) , A::calc($v) and the following:

trait A {

function calc($v) {

return $v+1;

}

}

class MyClass {

use A {

calc as traitcalc;

}

function calc($v) {

$v++;

return traitcalc($v);

}

}

Nothing works.

Is there a way to make it work or must I override completely the trait function which is much more complex than this :)
stackoverflow 
august 2017 by broderboy
Xcode debugger doesn't print objects and shows nil, when they aren't
Xcode shows an error when trying to print an object with po <objectName> , but only for one project.

error: Couldn't materialize struct: size of variable <varName> disagrees with the ValueObject's size

Errored out in Execute, couldn't PrepareToExecuteJITExpression

The Xcode debugger also shows ALL objects as nil (self excluded), when they aren't (NSLog shows correct output, as seen in the image).

I don't know what's wrong with the project. Every other project works fine.

Any idea what it could be? (Cleaning the project had no effect.)
stackoverflow 
august 2017 by broderboy
Swift: delete all array elements
I am trying to delete all array elements with a for loop like this:

for index 1...myArray.count {

myArray.removeAtIndex(index)

}

But it doesn't work, I get this error before bulding:

Expected ';' in 'for' statement
stackoverflow 
august 2017 by broderboy
Core Data: Query objectIDs in a predicate?
I am fetching a set of objects from a Core Data persistent store using a fetch request and a predicate. My current predicate simply checks whether an attribute is >= a certain value. This all works great, except that I want to finally exclude any objects that are currently held in an array.

I basically need to be able to exclude a set of objects, and the only way I think I can do this is to be able to get a list of objectID from my managed objects array, and create another expression in my predicate to ensure that any objects returned don't have the same objectID . I.E.@"ANY records.objectID NOT IN %@", arrayOfObjectID .

How can I do this?
stackoverflow 
july 2017 by broderboy
How to Determine if PHPUnit Tests are Running?
I currently have a problem that I have to work around in legacy code to get our interaction with a PHP Extension to work properly (Singleton Testing Question ).

As such, I do not want to execute this code when running our normal production code with the application. Therefore, I need to check in regular PHP code if the code being executed is being executed as part of a test or not.

Any suggestions on how to determine this? I thought about a defined variable tied to the presence of the test files themselves (we do not ship the tests to customers) but our developers need the Extension to work normally, while the CI server needs to run the tests.

Would a Global set in the PHPUnit.xml file be recommended? Other thoughts?
stackoverflow 
july 2017 by broderboy
Prevent nginx 504 Gateway timeout using PHP set_time_limit()
I am getting 504 timeouts message from nginx when my PHP script is running longer than usual. set_time_limit(0) does not seem to prevent that! Does it not work when running php5-fpm on nginx? If so, whats the proper way of setting the time limit?

Error:

504 Gateway Time-out

nginx/1.2.7
stackoverflow 
july 2017 by broderboy
Controlling which view controller loads after receiving a push notification in SWIFT
Once I receive a push notification and swipe to open it, it just opens my app and not the VC I want.

So my question is how do I load the VC I want? I know if the app is open I would move the VC over to another inside the didReceiveRemoteNotification but how do I do it if the app isn't open? or if it is in background mode?

Also I have TWO different push notifications, so therefore I need it to move ONE of TWO different VCs. How can I tell the difference between different push notifactions?

Thanks.
stackoverflow 
july 2017 by broderboy
How do I check if a string contains a specific word?
Consider:

$a = 'How are you?';

if ($a contains 'are')

echo 'true';

Suppose I have the code above, what is the correct way to write the statement if ($a contains 'are') ?
stackoverflow 
july 2017 by broderboy
How to present UIAlertController when not in a view controller?
Scenario: The user taps on a button on a view controller. The view controller is the topmost (obviously) in the navigation stack. The tap invokes a utility class method called on another class. A bad thing happens there and I want to display an alert right there before control returns to the view controller.

+ (void)myUtilityMethod {

// do stuff

// something bad happened, display an alert.

}

This was possible with UIAlertView (but perhaps not quite proper).

In this case, how do you present a UIAlertController , right there in myUtilityMethod ?
stackoverflow 
july 2017 by broderboy
Fire a method from a Static Cell in a Table view Controller
In my code i have a table with static cell inside storyboards. I'm trying to fire a method upon clicking the last static cell.

What should i write in the code to make this happen. How can i refer static cells inside the code without firing error.
stackoverflow 
july 2017 by broderboy
Make column not nullable in a Laravel migration
I'm writing a migration to make certain columns in a table nullable right now. For the down function, I of course want to make those columns not nullable again. I looked through the schema builder docs , but couldn't see a way to do this.

Any help would be appreciated.
stackoverflow 
july 2017 by broderboy
How to update pods to Swift 3.0
Currently in the process of migrating to Swift 3.0. This is my first time doing anything like this and I am not entirely sure how to deal with the various pods I am using. For example I am using the pod SwiftDate: https://github.com/malcommac/SwiftDate . The Swift 3.0 branch isn't on the master so I assume running pod update won't pull the Swift 3.0 version. Am I correct in putting pod:

'SwiftDate', :git => 'https://github.com/malcommac/SwiftDate.git', :branch => 'feature/swift-3.0'

into my podfile and then running the update? Checking the github page seems this is the correct branch. Do branches only need to be specified like this when the Swift 3.0 version isn't on the master? Any tips and pointers on this would be greatly appreciated! Thanks!
stackoverflow 
july 2017 by broderboy
CocoaPods and Swift 3.0
I just want to try Swift 3.0 in one of my projects. Xcode open the migration window to update my project to use Swift 3.0.

The problem is, I just want to to update my project, and leave the Pods project untouched because any changes will be discard after I run the pod install again.

Anyone already have a solution for that?
stackoverflow 
july 2017 by broderboy
Swift, could not cast value of type
I created a subclass of UICollectionViewController and called it LibraryCollectionViewController , and marked both checkboxes for the project and test. Also it's storyboard id is LibraryCollectionViewController and set its corresponding class on interface builder.

Being new to Swift and iOS Testing I went and attempted to instantiate said view controller inside my test case as follows:

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let libraryCollectionVC = storyboard.instantiateViewControllerWithIdentifier("LibraryCollectionViewController") as! LibraryCollectionViewController

And I'm getting the following error:

Could not cast value of type 'MyApp.LibraryCollectionViewController' (0x1010b01f0) to 'MyAppTests.LibraryCollectionViewController' (0x10bd7f580).

So it is clear that it isn't casting, but as I'm still new to Swift, I find myself unable to determine if the error itself is being caused by:

I did something wrong when creating the subclass and I'm referencing a different one (Ergo the MyApp.[vc] vs MyAppTests.[vc])

The casting using as! is incorrect

Any other reason

Any help would be appreciate, thanks in advance.

Update 1: When I was creating the view controller, the last step shows 2 checkboxes under a Target header, I enabled both of them, could that be the cause?
stackoverflow 
july 2017 by broderboy
How do I get a PHP class constructor to call its parent's parent's constructor
I need to have a class constructor in PHP call its parent's parent's (grandparent?) constructor without calling the parent constructor.

// main class that everything inherits

class Grandpa

{

public function __construct()

{

}

}

class Papa extends Grandpa

{

public function __construct()

{

// call Grandpa's constructor

parent::__construct();

}

}

class Kiddo extends Papa

{

public function __construct()

{

// THIS IS WHERE I NEED TO CALL GRANDPA'S

// CONSTRUCTOR AND NOT PAPA'S

}

}

I know this is a bizarre thing to do and I'm attempting to find a means that doesn't smell bad but nonetheless, I'm curious if it's possible.

EDIT

I thought I should post the rationale for the chosen answer. The reason being; it most elegant solutionto the problem of wanting to call the "grandparent's" constructor while retaining all the values. It's certainly not the best approach nor is it OOP friendly, but that's not what the question was asking.

For anyone coming across this question at a later date - Please find another solution . I was able to find a much better approach that didn't wreak havoc on the class structure. So should you.
stackoverflow 
july 2017 by broderboy
Does PHPUnit have some inbuilt recursive array comparison function?
Some of the testing I will need to do will require comparing a known array with the result I am getting from the functions I will be running.

For comparing arrays recursively:

Does PHPUnit have an inbuilt function?

Does someone here have some code they have constructed to share?

Will this be something I will have to construct on my own?
stackoverflow 
july 2017 by broderboy
Navigation bar with multiple buttons
I have a navigation bar with a left and right button, and I need to put another button next to the right button. Does anyone know how I can go about this? Here is some code to help:

- (id)init {

self = [super initWithStyle:UITableViewStyleGrouped];

if (self) {

_pinArray = [[NSArray alloc]init];

_pinArray = [Data singleton].annotations;

UIBarButtonItem *right = [[UIBarButtonItem alloc]initWithTitle:@"Map"

style:UIBarButtonItemStylePlain

target:self

action:@selector(goToMap:)];

self.navigationItem.rightBarButtonItem = right;

UIBarButtonItem *left = [[UIBarButtonItem alloc]initWithTitle:@"Menu"

style:UIBarButtonItemStylePlain

target:self

action:@selector(goToMenu:)];

self.navigationItem.leftBarButtonItem = left;

self.navigationItem.title = @"My Homes";

}

return self;

}
stackoverflow 
july 2017 by broderboy
Adding observer for KVO without pointers using Swift
In Objective-C, I would normally use something like this:

static NSString *kViewTransformChanged = @"view transform changed";

// or

static const void *kViewTransformChanged = &kViewTransformChanged;

[clearContentView addObserver:self

forKeyPath:@"transform"

options:NSKeyValueObservingOptionNew

context:&kViewTransformChanged];

I have two overloaded methods to choose from to add an observer for KVO with the only difference being the context argument:

clearContentView.addObserver(observer: NSObject?, forKeyPath: String?, options: NSKeyValueObservingOptions, context: CMutableVoidPointer)

clearContentView.addObserver(observer: NSObject?, forKeyPath: String?, options: NSKeyValueObservingOptions, kvoContext: KVOContext)

With Swift not using pointers, I'm not sure how to dereference a pointer to use the first method.

If I create my own KVOContext constant for use with the second method, I wind up with it asking for this:

let test:KVOContext = KVOContext.fromVoidContext(context: CMutableVoidPointer)

EDIT: What is the difference between CMutableVoidPointer and KVOContext? Can someone give me an example how how to use them both and when I would use one over the other?

EDIT #2: A dev at Apple just posted this to the forums: KVOContext is going away; using a global reference as your context is the way to go right now.
stackoverflow 
june 2017 by broderboy
dealloc in Swift
I would like to perform some cleanup at the end of a view controller's life, namely to remove an NSNotificationCenter notification. Implementing dealloc results in a Swift compiler error:

Cannot override 'dealloc' which has been marked unavailable

What is the preferred way to perform some cleanup at the end of an object's life in Swift?
stackoverflow 
june 2017 by broderboy
Entitlements file do not match those specified in your provisioning profile.(0xE8008016)
The executable was signed with invalid entitlements.

The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.(0xE8008016).

I am getting this error. please help me.

I have create the provisioning profile and change the bundle id. I have enable the keychain sharing from Target->Capabilities and generate the new .entitlement file. and i have also change the bundle id in that.
stackoverflow 
june 2017 by broderboy
NSPhotoLibraryUsageDescription key must be present in Info.plist to use camera roll
Recently I started to get this error:

NSPhotoLibraryUsageDescription key must be present in Info.plist to

use camera roll.

I am using React Native to build my app (I am not familiar with ios native development) and I don't know how to add this key to Info.plist

Can you post an example? Thanks

I am using npm package "react-native-camera-roll-picker": "^1.1.7"
stackoverflow 
june 2017 by broderboy
« earlier      
per page:    204080120160

Copy this bookmark:



description:


tags: