broderboy + stackoverflow   148

OpenURL in iOS10
So apparently OpenURL has been depreciated in iOS 10. Does anyone have any documentation on why or can explain what to do next? I looked on the Apple site already and found a few things pertaining to OpenURL and this is what they say to use now:

UIApplication.shared().open(url: URL, options: [String: AnyObject], completionHandler: ((Bool) -> Void)?)

Does anyone have any evidence that this is the new way to use OpenURL in Swift 3.0? In addition what values are to be used in the options: and completionHandler: parameters respectively?
stackoverflow 
2 days ago by broderboy
How to "set a breakpoint in malloc_error_break to debug"
I'm getting lots of console outputs like this without my application crashing:

malloc: * error for object 0xc6a3970: pointer being freed was not

allocated * set a breakpoint in malloc_error_break to debug

How can I find out which object or variable is affected?

I tried setting a symbolic breakpoint like this but it never halts:
stackoverflow 
2 days ago by broderboy
Update Angular model after setting input value with jQuery
I have this simple scenario:

Input element which value is changed by jQuery's val() method.

I am trying to update the angular model with the value that jQuery set. I tried to write a simple directive, but it's not doing what I want.

Here's the directive:

var myApp = angular.module('myApp', []);

myApp.directive('testChange', function() {

return function(scope, element, attrs) {

element.bind('change', function() {

console.log('value changed');

})

}

})

this is the jQuery part:

$(function(){

$('button').click(function(){

$('input').val('xxx');

})

})

and html:

<div ng-app="myApp">

<div ng-controller="MyCtrl">

<input test-change ng-model="foo" />

<span></span>

</div>

</div>

<button>clickme</button>

Here is the fiddle with my try:

http://jsfiddle.net/U3pVM/743/

Can someone please point me in the right direction?
stackoverflow 
3 days ago by broderboy
Correct way to retrieve a single object from Realm database
I am absolutely loving Realm (0.92) in combination with Swift but have a question about reading an object from the database. My goal is to retrieve a single object with a known, unique ID (which also happens to be the primary key.

All the documentation appears to be oriented around queries for multiple objects which are then filtered. In this case I know the object ID and, since it is known to be unique, would like to retrieve it directly.

My current approach is as follows:

Realm().objects(Book).filter("id == %@", prevBook.nextID).first

This seems heavy-handed. Documentation from prior versions suggest that there is a more direct way but I can't seem to locate it in the documentation.

The problem with my current approach is that it is crashing with an exception on the following function:

public func filter(predicateFormat: String, _ args: CVarArgType...) -> Results<T>

The exception is mysteriously reported as:

EXC_BAD_ACCESS (code=1, address=0xedf)

Any suggestions are very welcome.

Anticipating one line of questioning: I have confirmed that replacing prevBook.nextID with a known, good ID does not solve the problem
stackoverflow 
3 days ago by broderboy
Create tap-able "links" in the NSAttributedString of a UILabel?
I have been searching this for hours but I've failed. I probably don't even know what I should be looking for.

Many applications have text and in this text are web hyperlinks in rounded rect. When I click them UIWebView opens. What puzzles me is that they often have custom links, for example if words starts with # it is also clickable and the application responds by opening another view. How can I do that? Is it possible with UILabel or do I need UITextView or something else?
stackoverflow 
3 days ago by broderboy
iOS 7 and button and border
I am making my app ready for iOS7. I did conversion and was working with a user. The button in the app does not look like button. Looks very flat. Is there someway to put border or make it stand like a button?
stackoverflow 
3 days ago by broderboy
UIFont with custom font fails with Nil
I'm trying to add a custom font to my project in Xcode 4.2, but whenever I try to use it, I get a error that the object is nil.

I have done the following:

1) Added a row to my .plist 'Fonts provided by application' value: "LCDMono2 Ultra.ttf"

2) Added the font to my Supporting Files and showed it in XCode to verify it was added.

3) Verified using Get Info that the Full Name is "LCDMono2 Ultra"

4) Created the font in my project with:

UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16];

and I've tried this variant:

UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16.f];

5) Tried to use the font name (addObject:myFont.fontName) , generating the 'nil' error.

What could be causing the error? Could it be something like the space in the name?
stackoverflow 
3 days ago by broderboy
dispatch_after - GCD in swift?
I've gone through the iBook from Apple, and couldn't find any definition of it :

Can someone explain the structure of dispatch_after ?

dispatch_after(<#when: dispatch_time_t#>, <#queue: dispatch_queue_t?#>, <#block: dispatch_block_t?#>)
stackoverflow 
3 days ago by broderboy
Swift 2: guard in for loop?
what is the correct way to use guard inside a for loop?

for (index,user) in myUsersArray.enumerate() {

guard user.id != nil else {

print("no userId")

//neither break / return will keep running the for loop

}

if user.id == myUser.id {

//do stuff

}

}
stackoverflow 
3 days ago by broderboy
How to print call stack in Swift?
In Objective-C, you can print the call stack by doing the following:

NSLog(@"%@", [NSThread callStackSymbols]);

How do you do this in Swift without using Foundation class?
stackoverflow 
3 days ago by broderboy
AngularJS: 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 couple of stack posts but some how my example doesnt 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 refference.

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> cause I want to display it within the app.

I have been researching for more than a day now but some how I cant seem to understand how this works in angular.. and lets just assume the pdf viewer libraries out there weren't an option.
stackoverflow 
3 days ago by broderboy
Best architecture for many asynchronous Realm writes
I'm getting crashes from Realm writes already being in a transaction, due to Realm data being updated from several asynchronous network callbacks. I understand why Realm is crashing, but I'm wondering what the right architecture is here.

So far, I can minimize the crashes by moving the individual write transactions to background threads, but is this the recommended best practice? It relies on me remembering to do this every time. Or should the network requests all be run through some central clearing house, which then moves callbacks (and therefore writes) onto background threads? Or are background threads not even the right way to do this?
stackoverflow 
3 days ago by broderboy
Convert String to float in Apple's Swift
I'm trying to convert numbers taken from a UITextField, which I presume, are actually strings, and convert them to float, so I can multiply them.

I have two UITextfield s which are declared as follows:

@IBOutlet var wage: UITextField

@IBOutlet var hour: UITextField

When the user presses a UIButton I want to calculate the wages the user earns, but I can't, as I need to convert them to floats first, before I can use them.

I know how to convert them to an integer by doing this:

var wageConversion:Int = 0

wageConversion = wage.text.toInt()!

However, I have no idea how to convert them to floats.
stackoverflow 
3 days ago by broderboy
How can I tell AngularJS to "refresh"
I have a click event that happens outside the scope of my custom directive, so instead of using the "ng-click" attribute, I am using a jQuery.click() listener and calling a function inside my scope like so:

$('html').click(function(e) {

scope.close();

);

close() is a simple function that looks like this:

scope.close = function() {

scope.isOpen = false;

}

In my view, I have an element with "ng-show" bound to isOpen like this:

<div ng-show="isOpen">My Div</div>

When debugging, I am finding that close() is being called, isOpen is being updated to false, but the AngularJS view is not updating. Is there a way I can manually tell Angular to update the view? Or is there a more "Angular" approach to solving this problem that I am not seeing?
stackoverflow 
3 days ago by broderboy
Xcode 8 Beta 3 Use Legacy Swift issue
I have an Objective-C project in Xcode 8 Beta 3. Since updating, whenever I try to build I receive the following error:

“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

Has anyone encountered this? Since it's an Objective-C project there's no build setting to configure Swift. I have also made sure none of the project dependencies or CocoaPods are using Swift. The only solution I have is to use Beta 2. Any ideas how I might fix this issue?

I should also mention I'm running OSX 10.12 Beta 2.
stackoverflow 
3 days ago by broderboy
Using a dispatch_once singleton model in Swift
I'm trying to work out an appropriate singleton model for usage in Swift. So far, I've been able to get a non-thread safe model working as:

class var sharedInstance:TPScopeManager {

get {

struct Static {

static var instance : TPScopeManager? = nil

}

if !Static.instance {

Static.instance = TPScopeManager()

}

return Static.instance!

}

}

Wrapping the singleton instance in the Static struct should allow a single instance that doesn't collide with singleton instances without complex naming schemings, and it should make things fairly private. Obviously though, this model isn't thread safe, so I tried to add dispatch_once to the whole thing:

class var sharedInstance:TPScopeManager {

get {

struct Static {

static var instance : TPScopeManager? = nil

static var token : dispatch_once_t = 0

}

dispatch_once(Static.token) { Static.instance = TPScopeManager() }

return Static.instance!

}

}

But I get a compiler error on the dispatch_once line:

Cannot convert the expression's type 'Void' to type '()'

I've tried several different variants of the syntax, but they all seem to have the same results:

dispatch_once(Static.token, { Static.instance = TPScopeManager() })

What is the proper usage of dispatch_once using Swift? I initially thought the problem was with the block due to the () in the error message, but the more I look at it, the more I think it may be a matter of getting the dispatch_once_t correctly defined.
stackoverflow 
3 days ago by broderboy
Installing Apple's Network Link Conditioner Tool
I have installed xcode 4.3.1 on my machine running Lion.

I can't find the Network Link Conditioner tool anywhere.

I have checked the utilities folder, also the xcode/contents/developer/* directories.. no such luck.

Do I need to install specific components or has this tool been removed or renamed recently?
stackoverflow 
3 days ago by broderboy
Is there a way to 'uniq' by column?
I have a .csv file like this:

stack2@example.com,2009-11-27 01:05:47.893000000,example.net,127.0.0.1

overflow@example.com,2009-11-27 00:58:29.793000000,example.net,255.255.255.0

overflow@example.com,2009-11-27 00:58:29.646465785,example.net,256.255.255.0

...

I have to remove duplicate e-mails (the entire line) from the file (i.e. one of the lines containing overflow@example.com in the above example). How do I use uniq on only field 1 (separated by commas)? According to man , uniq doesn't have options for columns.

I tried something with sort | uniq but it doesn't work.
stackoverflow 
3 days ago by broderboy
Opening Realm file in browser always requires an encryption key
I'm using Realm Browser 0.9.85 and using the examples in https://github.com/realm/realm-cocoa .

I'm a total Realm newbie so go easy on me. Every time I try to open up a Realm file from the example from GitHub, I get a request to enter in the encryption key. It seems like the default configuration in Realm is to not have it's db be encrypted, so I don't know what gives. Any help would be greatly appreciated. Thanks.
stackoverflow 
3 days ago by broderboy
cURL error 60: SSL certificate: unable to get local issuer certificate
I use WAMP on a local development environment and am trying to charge a credit card but get the error message:

cURL error 60: SSL certificate problem: unable to get local issuer certificate

I searched a lot on Google and lots of people are suggesting that I download this file: cacert.pem , put it somewhere and reference it in my php.ini. This is the part in my php.ini:

curl.cainfo = "C:\Windows\cacert.pem"

Yet, even after restarting my server several times and changing the path, I get the same error message.

I use WAMP from the Apache Modules and have the ssl_module enabled. And from the PGP extensions I have php_curl enabled.

Still the same error message. Why is that happening?

Now I am following this fix: How to fix PHP CURL Error 60 SSL

Which suggests that I add these lines to my cURL options:

curl_setopt($process, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');

curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true);

Where do I add options to my cURL? Apparently not through the command line, since my CLI doesn't find the command "curl_setopt"

EDIT

This is the code I am running:

public function chargeStripe()

{

$stripe = new Stripe;

$stripe = Stripe::make(env('STRIPE_PUBLIC_KEY'));

$charge = $stripe->charges()->create([

'amount' => 2900,

'customer' => Input::get('stripeEmail'),

'currency' => 'EUR',

]);

dd($charge);

// echo $charge[Input::get('stripeToken')];

return Redirect::route('step1');

}
stackoverflow 
3 days ago by broderboy
Specify sudo password for Ansible
How do I specify a sudo password for Ansible in non-interactive way?

I'm running Ansible playbook like this:

ansible-playbook playbook.yml -i inventory.ini --user=username --ask-sudo-pass

But I want to run it like this:

ansible-playbook playbook.yml -i inventory.ini --user=username --sudo-pass=12345

Is there a way? I want to automate my project deployment as much as possible.
stackoverflow 
3 days ago by broderboy
#pragma mark in Swift?
In Objective C, I can use #pragma mark to mark sections of my code in the symbol navigator. Since this is a C preprocessor command, it's not available in Swift. Is there a stand-in for this in Swift, or do I have to use ugly comments?
stackoverflow 
3 days ago by broderboy
Laravel daily log created with wrong permissions
I have a script that I run using php artisan (with root user), and sometimes it causes the daily log file to be created before the apache www-data user does - which means that when a real user uses my web application, I get the folder permission error:

Failed to open stream: Permission denied

I change the permissions back to www-data everytime but I want to solve this by having the log file always created with the correct permissions.

I've considered creating a cron job that creates the file or touches it to make sure it has the right permission everyday, but I'm looking for a better solution that doesn't rely on another script.

We've also considered wrapping php artisan in another script to make sure that it is always run with the www-data credentials, but somethings that we want to do are actually root procedures that apache should not be allowed to do.

Any more suggestions?
stackoverflow 
3 days ago by broderboy
dyld: Library not loaded: @rpath/libswiftCore.dylib
I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.

I have tried

Restarting Xcode, iPhone, computer

Cleaning & rebuilding

Revoking and creating new certificate/provision profile

Runpath Search Paths is $(inherited) @executable_path/Frameworks

Embedded Content Contains Swift Code is 'Yes'

Code Signing Identity is developer

Below is the error in entirety

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

Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName

Reason: no suitable image found. Did find:

/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at

address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping

/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
stackoverflow 
3 days ago by broderboy
How do I convert NSMutableArray to NSArray?
How do I convert NSMutableArray to NSArray in objective-c ?
stackoverflow 
3 days ago by broderboy
How to add a long pause for AVSpeechSynthesizer?
I found -- can add a small pause like the number count down:

10--9--8--7--6--5--4--3--2--1--

But I don't know how to add a long pause, for like 1 sec?

Any idea?
stackoverflow 
3 days ago by broderboy
Precision String Format Specifier In Swift
Below is how I would have previously truncated a float to two decimal places

NSLog(@" %.02f %.02f %.02f", r, g, b);

I checked the docs and the eBook but haven't been able to figure it out. Thanks!
stackoverflow 
3 days ago by broderboy
Getting error "No such module" using Xcode, but the framework is there
I'm currently coding in Swift, and I've got an error:

No such module Social

But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".

The frameworks is in Objective-C, so I wrote a Bridge Header for it.

Please, how can I make Xcode recognize the framework?
stackoverflow 
3 days ago by broderboy
How to get First and Last Day of Previous Month with Carbon - Laravel
I need First and Last Day of Previous Month using Carbon Library, what I have tried is as follows:

$firstDayofPreviousMonth = Carbon::now()->startOfMonth()->subMonth()->toDateString();

$lastDayofPreviousMonth = Carbon::now()->endOfMonth()->subMonth()->toDateString();

Result I'm getting is for $firstDayofPreviousMonth = '2016-04-01'(as current month is 5th(May)) and for $lastDayofPreviousMonth = '2016-05-01'.

I'm getting correct result for $firstDayofPreviousMonth, but it's giving me 30 days previous result, and giving me wrong result for $lastDayofPreviousMonth.

Can anyone help me out with this? Thank you
stackoverflow 
3 days ago by broderboy
Using Auto Layout in UITableView for dynamic cell layouts & variable row heights
How do you use Auto Layout within UITableViewCell s in a table view to let each cell's content and subviews determine the row height, while maintaining smooth scrolling performance?
stackoverflow 
3 days ago by broderboy
How do I check if a string contains a specific word in PHP?
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 
3 days ago by broderboy
XCODE 7.1 Swift 2 Unknown class in Interface Builder file
I've created new Cocoa Touch File. Named it SwipingViewController.

Then try to add Custom Class to ViewController.

And when I run the app i receive an error

2015-10-09 10:53:25.054 ParseStarterProject[5369:389307] Unknown class SwipingViewController in Interface Builder file.

I've tried to find in Google by myself.

I've found some solutions

Xcode 6 Strange Bug: Unknown class in Interface Builder file

But they all did not help to fix the problem.

Any idea how to fix it?

here is my projects files
stackoverflow 
3 days ago by broderboy
Specify sudo password for Ansible
How do I specify a sudo password for Ansible in non-interactive way?

I'm running Ansible playbook like this:

ansible-playbook playbook.yml -i inventory.ini --user=username --ask-sudo-pass

But I want to run it like this:

ansible-playbook playbook.yml -i inventory.ini --user=username --sudo-pass=12345

Is there a way? I want to automate my project deployment as much as possible.
stackoverflow 
7 days ago by broderboy
How to add a long pause for AVSpeechSynthesizer?
I found -- can add a small pause like the number count down:

10--9--8--7--6--5--4--3--2--1--

But I don't know how to add a long pause, for like 1 sec?

Any idea?
stackoverflow 
18 days ago by broderboy
Opening Realm file in browser always requires an encryption key
I'm using Realm Browser 0.9.85 and using the examples in https://github.com/realm/realm-cocoa .

I'm a total Realm newbie so go easy on me. Every time I try to open up a Realm file from the example from GitHub, I get a request to enter in the encryption key. It seems like the default configuration in Realm is to not have it's db be encrypted, so I don't know what gives. Any help would be greatly appreciated. Thanks.
stackoverflow 
28 days ago by broderboy
Is there a way to 'uniq' by column?
I have a .csv file like this:

stack2@example.com,2009-11-27 01:05:47.893000000,example.net,127.0.0.1

overflow@example.com,2009-11-27 00:58:29.793000000,example.net,255.255.255.0

overflow@example.com,2009-11-27 00:58:29.646465785,example.net,256.255.255.0

...

I have to remove duplicate e-mails (the entire line) from the file (i.e. one of the lines containing overflow@example.com in the above example). How do I use uniq on only field 1 (separated by commas)? According to man , uniq doesn't have options for columns.

I tried something with sort | uniq but it doesn't work.
stackoverflow 
4 weeks ago by broderboy
Best architecture for many asynchronous Realm writes
I'm getting crashes from Realm writes already being in a transaction, due to Realm data being updated from several asynchronous network callbacks. I understand why Realm is crashing, but I'm wondering what the right architecture is here.

So far, I can minimize the crashes by moving the individual write transactions to background threads, but is this the recommended best practice? It relies on me remembering to do this every time. Or should the network requests all be run through some central clearing house, which then moves callbacks (and therefore writes) onto background threads? Or are background threads not even the right way to do this?
stackoverflow 
5 weeks ago by broderboy
How to get First and Last Day of Previous Month with Carbon - Laravel
I need First and Last Day of Previous Month using Carbon Library, what I have tried is as follows:

$firstDayofPreviousMonth = Carbon::now()->startOfMonth()->subMonth()->toDateString();

$lastDayofPreviousMonth = Carbon::now()->endOfMonth()->subMonth()->toDateString();

Result I'm getting is for $firstDayofPreviousMonth = '2016-04-01'(as current month is 5th(May)) and for $lastDayofPreviousMonth = '2016-05-01'.

I'm getting correct result for $firstDayofPreviousMonth, but it's giving me 30 days previous result, and giving me wrong result for $lastDayofPreviousMonth.

Can anyone help me out with this? Thank you
stackoverflow 
6 weeks ago by broderboy
Swift 2: guard in for loop?
what is the correct way to use guard inside a for loop?

for (index,user) in myUsersArray.enumerate() {

guard user.id != nil else {

print("no userId")

//neither break / return will keep running the for loop

}

if user.id == myUser.id {

//do stuff

}

}
stackoverflow 
6 weeks ago by broderboy
UIFont with custom font fails with Nil
I'm trying to add a custom font to my project in Xcode 4.2, but whenever I try to use it, I get a error that the object is nil.

I have done the following:

1) Added a row to my .plist 'Fonts provided by application' value: "LCDMono2 Ultra.ttf"

2) Added the font to my Supporting Files and showed it in XCode to verify it was added.

3) Verified using Get Info that the Full Name is "LCDMono2 Ultra"

4) Created the font in my project with:

UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16];

and I've tried this variant:

UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16.f];

5) Tried to use the font name (addObject:myFont.fontName) , generating the 'nil' error.

What could be causing the error? Could it be something like the space in the name?
stackoverflow 
7 weeks ago by broderboy
iOS 7 and button and border
I am making my app ready for iOS7. I did conversion and was working with a user. The button in the app does not look like button. Looks very flat. Is there someway to put border or make it stand like a button?
stackoverflow 
8 weeks ago by broderboy
Correct way to retrieve a single object from Realm database
I am absolutely loving Realm (0.92) in combination with Swift but have a question about reading an object from the database. My goal is to retrieve a single object with a known, unique ID (which also happens to be the primary key.

All the documentation appears to be oriented around queries for multiple objects which are then filtered. In this case I know the object ID and, since it is known to be unique, would like to retrieve it directly.

My current approach is as follows:

Realm().objects(Book).filter("id == %@", prevBook.nextID).first

This seems heavy-handed. Documentation from prior versions suggest that there is a more direct way but I can't seem to locate it in the documentation.

The problem with my current approach is that it is crashing with an exception on the following function:

public func filter(predicateFormat: String, _ args: CVarArgType...) -> Results<T>

The exception is mysteriously reported as:

EXC_BAD_ACCESS (code=1, address=0xedf)

Any suggestions are very welcome.

Anticipating one line of questioning: I have confirmed that replacing prevBook.nextID with a known, good ID does not solve the problem
stackoverflow 
8 weeks ago by broderboy
Create tap-able "links" in the NSAttributedString of a UILabel?
I have been searching this for hours but I've failed. I probably don't even know what I should be looking for.

Many applications have text and in this text are web hyperlinks in rounded rect. When I click them UIWebView opens. What puzzles me is that they often have custom links, for example if words starts with # it is also clickable and the application responds by opening another view. How can I do that? Is it possible with UILabel or do I need UITextView or something else?
stackoverflow 
8 weeks ago by broderboy
NSNotification with delay
How to post NSNotification with delay.

One solution that is in my mind :- post notification in performSelectorAfterDelay method. Is there any better solution for this.

Is NSNotificationQueue can help me to achieve this ?
stackoverflow 
8 weeks ago 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 
9 weeks ago by broderboy
OpenURL in iOS10
So apparently OpenURL has been depreciated in iOS 10. Does anyone have any doccumentation on why or can explain what to do next? I looked on the Apple site already and found a few things pertaining to OpenURL and this is what they say to use now:

UIApplication.shared().open(url: URL, options: [String: AnyObject], completionHandler: ((Bool) -> Void)?)

Does anyone have any evidence that this is the new way to use OpenURL in Swift 3.0? In addition what values are to be used in the options: and completionHandler: parameters respectively?
stackoverflow 
9 weeks ago 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 
9 weeks ago 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 
10 weeks ago 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 
11 weeks ago by broderboy
How can i run Laravel Queue only once?
I used laravel 5.1 Queue for my background function with async.

But i want to run that function for only 1 time. If that function fail, i want to do other process.

How can i detect my job is failed or not?

Am i doing right or wrong ? What should i change?

ps: I'm beginner. I used like this in my controller.

$job = new myjob($var1, $var2);

$this->dispatch($job);

$job->release();

if ($job->attempts() >= 1)

{

$job->delete();

//will do other process

}
stackoverflow 
february 2017 by broderboy
How do I convert NSMutableArray to NSArray?
How do I convert NSMutableArray to NSArray in objective-c ?
stackoverflow 
february 2017 by broderboy
What is "Constrain to margin" in Storyboard in Xcode 6
I am Working with autolayout and constraints and found there is a Constrain to margins option in XCode 6 which was not present in XCode 5 and is checked by default.

I created a test project then I added a UITableView on a ViewController with the frame set to the same size as view and added constraints

XCode 6

You can see here even though tableview has the same frame as view XCode suggests to add -16 as constraint whereas XCode 5 would suggest adding spacing 0.

Now when you uncheck "Constrain to margin" option it behaves same as XCode 5 and would suggest adding 0 as constraint

Also, I found that once I add constraint with Constrain to margin checked, I am no longer able to open the storyboard file in XCode 5 so it's definitely something new in XCode 6

Hopefully, I am able to explain my question properly. I would like to understand what "Constrain to margin" actually does and when I should and should not use it. I do apologize if it's something very simple and obvious.

EDIT

I found something about layout margins in discussion here , I wonder if it's related to this.
stackoverflow 
february 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 
february 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 
february 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 
february 2017 by broderboy
XCODE 7.1 Swift 2 Unknown class in Interface Builder file
I've created new Cocoa Touch File. Named it SwipingViewController.

Then try to add Custom Class to ViewController.

And when I run the app i receive an error

2015-10-09 10:53:25.054 ParseStarterProject[5369:389307] Unknown class SwipingViewController in Interface Builder file.

I've tried to find in Google by myself.

I've found some solutions

Xcode 6 Strange Bug: Unknown class in Interface Builder file

But they all did not help to fix the problem.

Any idea how to fix it?

here is my projects files
stackoverflow 
february 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 
february 2017 by broderboy
What is the swift equivalent of respondsToSelector?
I've googled but not been able to find out what the swift equivalent to respondsToSelector: is.

This is the only thing I could find (Swift alternative to respondsToSelector: ) but isn't too relevant in my case as its checking the existence of the delegate, I don't have a delegate I just want to check if a new API exists or not when running on the device and if not fall back to a previous version of the api.
stackoverflow 
february 2017 by broderboy
How to Support Dynamic Type in Labels in iOS 7
How do I support Dynamic Type in UILabel and UITextView in iOS 7? I'm adapting one of our projects for iOS 7 and would like to support this accessibility feature. I can't find the specific how to tutorial on it on Apple's iOS Developer site. Any links or sample code would be appreciated.
stackoverflow 
february 2017 by broderboy
Error while installing Nokogiri (1.6.7) on El Capitan
One of my developers have updated Nokogiri, and when pulling the updated Gemfile my bundle install fails.

➜ my-project git:(master) bundle install

Fetching source index from https://rubygems.org/

Using rake 10.4.2

Using i18n 0.7.0

Using json 1.8.3

Using minitest 5.8.3

Using thread_safe 0.3.5

Using tzinfo 1.2.2

Using activesupport 4.2.3

Using builder 3.2.2

Using erubis 2.7.0

Using mini_portile2 2.0.0

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby extconf.rb --use-system-libraries

checking if the C compiler accepts ... yes

checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no

Building nokogiri using system libraries.

libxml2 version 2.6.21 or later is required!

*** extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of necessary

libraries and/or headers. Check the mkmf.log file for more details. You may

need configuration options.

Provided configuration options:

--with-opt-dir

--without-opt-dir

--with-opt-include

--without-opt-include=${opt-dir}/include

--with-opt-lib

--without-opt-lib=${opt-dir}/lib

--with-make-prog

--without-make-prog

--srcdir=.

--curdir

--ruby=/Users/me/.rvm/rubies/ruby-2.1.2/bin/ruby

--help

--clean

--use-system-libraries

--with-zlib-dir

--without-zlib-dir

--with-zlib-include

--without-zlib-include=${zlib-dir}/include

--with-zlib-lib

--without-zlib-lib=${zlib-dir}/lib

--with-xml2-dir

--without-xml2-dir

--with-xml2-include

--without-xml2-include=${xml2-dir}/include

--with-xml2-lib

--without-xml2-lib=${xml2-dir}/lib

--with-libxml-2.0-config

--without-libxml-2.0-config

--with-pkg-config

--without-pkg-config

--with-xslt-dir

--without-xslt-dir

--with-xslt-include

--without-xslt-include=${xslt-dir}/include

--with-xslt-lib

--without-xslt-lib=${xslt-dir}/lib

--with-libxslt-config

--without-libxslt-config

--with-exslt-dir

--without-exslt-dir

--with-exslt-include

--without-exslt-include=${exslt-dir}/include

--with-exslt-lib

--without-exslt-lib=${exslt-dir}/lib

--with-libexslt-config

--without-libexslt-config

extconf failed, exit code 1

Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.1.2@my-project/gems/nokogiri-1.6.7 for inspection.

Results logged to /Users/me/.rvm/gems/ruby-2.1.2@my-project/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.7/gem_make.out

An error occurred while installing nokogiri (1.6.7), and Bundler cannot continue.

Make sure that `gem install nokogiri -v '1.6.7'` succeeds before bundling.

As suggested in "Failing to install Nokogiri gem " I have unsuccessfully tried to run:

bundle config build.nokogiri --use-system-libraries

bundle install

As suggested in "Failing to install Nokogiri gem " I also tried:

gem install nokogiri -- --use-system-libraries

and:

gem install nokogiri -v 1.6.5 -- --use-system-libraries

My OS version is El Capitan 10.11.2, and I have checked that the Xcode licence agreement has been accepted.

Any ideas how to get the Nokogiri installation to succeed?
stackoverflow 
february 2017 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 
january 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 
january 2017 by broderboy
AngularJS: 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 couple of stack posts but some how my example doesnt 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 refference.

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> cause I want to display it within the app.

I have been researching for more than a day now but some how I cant seem to understand how this works in angular.. and lets just assume the pdf viewer libraries out there weren't an option.
stackoverflow 
january 2017 by broderboy
Installing Apples Network Link Conditioner Tool
I have installed xcode 4.3.1 on my machine running Lion.

I can't find the Network Link Conditioner tool anywhere.

I have checked the utilities folder, also the xcode/contents/developer/* directories.. no such luck.

Do I need to install specific components or has this tool been removed or renamed recently?
stackoverflow 
january 2017 by broderboy
Xcode 8 Beta 3 Use Legacy Swift issue
I have an Objective-C project in Xcode 8 Beta 3. Since updating, whenever I try to build I receive the following error:

“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choose a Swift version or use the Build Settings editor to configure the build setting directly.

Has anyone encountered this? Since it's an Objective-C project there's no build setting to configure Swift. I have also made sure none of the project dependencies or CocoaPods are using Swift. The only solution I have is to use Beta 2. Any ideas how I might fix this issue?

I should also mention I'm running OSX 10.12 Beta 2.
stackoverflow 
january 2017 by broderboy
Using a dispatch_once singleton model in Swift
I'm trying to work out an appropriate singleton model for usage in Swift. So far, I've been able to get a non-thread safe model working as:

class var sharedInstance:TPScopeManager {

get {

struct Static {

static var instance : TPScopeManager? = nil

}

if !Static.instance {

Static.instance = TPScopeManager()

}

return Static.instance!

}

}

Wrapping the singleton instance in the Static struct should allow a single instance that doesn't collide with singleton instances without complex naming schemings, and it should make things fairly private. Obviously though, this model isn't thread safe, so I tried to add dispatch_once to the whole thing:

class var sharedInstance:TPScopeManager {

get {

struct Static {

static var instance : TPScopeManager? = nil

static var token : dispatch_once_t = 0

}

dispatch_once(Static.token) { Static.instance = TPScopeManager() }

return Static.instance!

}

}

But I get a compiler error on the dispatch_once line:

Cannot convert the expression's type 'Void' to type '()'

I've tried several different variants of the syntax, but they all seem to have the same results:

dispatch_once(Static.token, { Static.instance = TPScopeManager() })

What is the proper usage of dispatch_once using Swift? I initially thought the problem was with the block due to the () in the error message, but the more I look at it, the more I think it may be a matter of getting the dispatch_once_t correctly defined.
stackoverflow 
january 2017 by broderboy
How can I tell AngularJS to "refresh"
I have a click event that happens outside the scope of my custom directive, so instead of using the "ng-click" attribute, I am using a jQuery.click() listener and calling a function inside my scope like so:

$('html').click(function(e) {

scope.close();

);

close() is a simple function that looks like this:

scope.close = function() {

scope.isOpen = false;

}

In my view, I have an element with "ng-show" bound to isOpen like this:

<div ng-show="isOpen">My Div</div>

When debugging, I am finding that close() is being called, isOpen is being updated to false, but the AngularJS view is not updating. Is there a way I can manually tell Angular to update the view? Or is there a more "Angular" approach to solving this problem that I am not seeing?
stackoverflow 
january 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 
january 2017 by broderboy
Angular JS update input field after change
I'm trying to build a simple calculator in Angular in which I can override the total if I want. I have this part working but when I then go back to enter in a number in fields one or two the total isn't updated in the field.

Here is my jsfiddle http://jsfiddle.net/YUza7/2/

The form

<div ng-app>

<h2>Calculate</h2>

<div ng-controller="TodoCtrl">

<form>

<li>Number 1: <input type="text" ng-model="one">

<li>Number 2: <input type="text" ng-model="two">

<li>Total <input type="text" value="">

</form>

</div>

</div>

The javascript

function TodoCtrl($scope) {

$scope.total = function(){

return $scope.one * $scope.two;

};

}
stackoverflow 
january 2017 by broderboy
How do I check if a string contains a specific word in PHP?
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 
january 2017 by broderboy
cURL error 60: SSL certificate: unable to get local issuer certificate
I use wamp on a local development environment and am trying to charge a credit card but get the error message:

cURL error 60: SSL certificate problem: unable to get local issuer certificate

I googled a lot and lots of people are suggesting, that I download this file: cacert.pem

Put it somewhere and point through my php.ini to it. This is the part in my php.ini

curl.cainfo = "C:\Windows\cacert.pem"

Yet, even after restarting my server several times and changing the path, I get the same error message.

I use wamp from the Apache Modules and have the ssl_module enabled. And from the php extensions I have php_curl enabled.

Still the same error message. Wtf.

Now I am following this fix: How to fix PHP CURL Error 60 SSL

Which suggests that I add these lines to my cURL options:

curl_setopt($process, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');

curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true);

Where do I add options to my cURL? Apparently not through the command line, since my CLI doesn't find the command "curl_setopt"

EDIT

This is the code I am running:

public function chargeStripe()

{

$stripe = new Stripe;

$stripe = Stripe::make(env('STRIPE_PUBLIC_KEY'));

$charge = $stripe->charges()->create([

'amount' => 2900,

'customer' => Input::get('stripeEmail'),

'currency' => 'EUR',

]);

dd($charge);

// echo $charge[Input::get('stripeToken')];

return Redirect::route('step1');

}
stackoverflow 
january 2017 by broderboy
How to set a mail Subject in UIActivityViewController?
I want to set subject for email sharing in UIActivityViewController and also want to share in Twitter. I know in Twitter if we want to share — we need compress text to 140 chars. I checked many SO solutions, but nothing is working.

Is this issue fixed in latest iOS releases? Any other "working solutions"?
stackoverflow 
january 2017 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 
december 2016 by broderboy
Getting error "No such module" using Xcode, but the framework is there
I'm currently coding in Swift, and I've got an error:

No such module Social

But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".

The frameworks is in Objective-C, so I wrote a Bridge Header for it.

Please, how can I make Xcode recognize the framework?
stackoverflow 
december 2016 by broderboy
How to log a method's execution time exactly in milliseconds?
Is there a way to determine how much time a method needs to execute (in milliseconds)?
stackoverflow 
december 2016 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 
december 2016 by broderboy
dyld: Library not loaded: @rpath/libswiftCore.dylib
I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.

I have tried

Restarting Xcode, iPhone, computer

Cleaning & rebuilding

Revoking and creating new certificate/provision profile

Runpath Search Paths is $(inherited) @executable_path/Frameworks

Embedded Content Contains Swift Code is 'Yes'

Code Signing Identity is developer

Below is the error in entirety

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

Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName

Reason: no suitable image found. Did find:

/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at

address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping

/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
stackoverflow 
december 2016 by broderboy
How to override trait function and call it from the overriden 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 
december 2016 by broderboy
How to check if a string contains a specific word in PHP?
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 
december 2016 by broderboy
Set a border for UIButton in Storyboard
I can't get a border onto my buttons in XCode 5 without setting them directly in the code. Is it possible that there's no way to do this on the storyboard without making a custom background image?
stackoverflow 
december 2016 by broderboy
« earlier      
per page:    204080120160

Copy this bookmark:



description:


tags: