NSURLRequest not working on Yosemite Today extension

I am trying to create a Yosemite Notification Center widget for my personal use. It is supposed to capture a number from the server using NSURLRequest and NSURLConnection and display that number in the label. I am working in a normal Cocoa Objective-C application, so I don’t think there is a problem with my code, but I cannot get the same code to work in Today Extension. This is the error I get:

2014-11-04 13:07:00.178 B-Web mobile downloads[854:39027] ***storageTaskManagerExistsWithIdentifier:withIdentifier failed: Error Domain=NSCocoaErrorDomain Code=4099 "Couldn’t communicate with a helper application." (The connection to service named com.apple.nsurlstorage-cache was invalidated.) UserInfo=0x60000026e6c0 {NSDebugDescription=The connection to service named com.apple.nsurlstorage-cache was invalidated.}; {
    NSDebugDescription = "The connection to service named com.apple.nsurlstorage-cache was invalidated.";
}

.m for Today Extension here . The url where I get the number is in my actual code, but I left it there. Just so you know, the response line and label are declared in .h. Why does this not work in Today Extension? Am I doing something wrong?

+4
source share
1 answer

I had the same problem and could solve it. The extension runs in the sandbox. You can allow outgoing connections in the sandbox by going to your project and selecting an extension target. Then go to the features section and enable outgoing connections.

+7
source

All Articles