1

I get the following error while load the json file with SFContentBlockerManager.reloadContentBlockerWithIdentifie

Optional(Error Domain=ContentBlockerErrorDomain Code=1 "(null)")

// This is my code to get attachment 

let documentDirectoryURL = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
let jsonFileUrl =  documentDirectoryURL.URLByAppendingPathComponent("phantom.json")
let data = NSData(contentsOfURL: jsonFileUrl)
let attachment = NSItemProvider(item: data,typeIdentifier: kUTTypeJSON as String)
let item = NSExtensionItem()
item.attachments = [attachment]
context.completeRequestReturningItems([item], completionHandler: nil);

// Following code for SFContentBlockerManager
try! SFContentBlockerManager.reloadContentBlockerWithIdentifier("\(NSBundle.mainBundle().bundleIdentifier).PhantomBlocker", completionHandler: {(error) in print(error)})
Eimantas
  • 48,927
  • 17
  • 132
  • 168
  • It's rather a code snippet than an error. What's the error, and what's your specific question? – dakab Oct 28 '15 at 09:29
  • while loading safari content blocker from json file from document directory. SFContentBlockerManager throw error . Optional(Error Domain=ContentBlockerErrorDomain Code=1 “(null)”) ..please help i am new on IOS development – Sanjeet Kumar Nonia Oct 28 '15 at 10:07
  • @SanjeetKumarNonia if you hav find the solution then please share with me becuase i got the same error. – Bandish Dave Jan 28 '16 at 11:26

2 Answers2

1

I was facing the same problem while running one of the open source project than after regular attempt i came to known that the app is using "Bundle Identifier" so i used that in the code and it started running.

Chandan Anand
  • 179
  • 1
  • 11
0

I guess you might have made a mistake in your json file. If you any type of error in the json file Xcode throws this error. There are some websites that validate you file. This should help you fix the issue.

For example:

  1. http://jsonlint.com
  2. https://jsonformatter.curiousconcept.com
Devapploper
  • 6,062
  • 3
  • 20
  • 41