Re: Swift function overloading - invoking func with specific parameter (in place of Any parameter) on passing Any object

2019-10-27 Thread Devarshi Kulshreshtha via Cocoa-dev
So the other thing which came to my mind was similar to what you have
suggested:

a. Declare Displayable protocol with func display()
b. Let each Model implement this protocol
c. Within forEach on children I can just bind and typecast to the protocol
and invoke display method on it

However this looks like an ugly solution to me as Model is now serving 2
responsibilities - i. Handle/ Store data, ii. Handle how the data is
displayed. The 2nd responsibility looks to me like more reasonable for a
controller or presenter class to implement rather than the model class,
hence I want to avoid that path.

On Sun, Oct 27, 2019 at 7:55 PM Andrew Thompson  wrote:

>
> > Is there any other elegant way to achieve the desired behavior without
> > using `if-let + typecasting`?
>
>
> One way is to use classes instead on structs and define display as a
> method on those classes. I’m no Swift  expert but I expect you may find
> value in making display() into a protocol.
>
>
> Andrew
>
>
>

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Swift function overloading - invoking func with specific parameter (in place of Any parameter) on passing Any object

2019-10-27 Thread Devarshi Kulshreshtha via Cocoa-dev
I have 3 structs:

struct Address: Codable {
var addressLine1: String
}
struct Person: Codable {
var name: String
}
struct Order: Codable {
var person: Person?
var address: Address?
}

In my ViewController class I am using Mirror to access each of the
properties within Order:

let address = Address(addressLine1: "Some unknown address")
let person = Person(name: "Some unknown name")
let order = Order(person: person, address: address)

let newOrderMirror = Mirror(reflecting: order)
newOrderMirror.children.forEach {
display(child: $0.value)
}

In ViewController I have implemented 3 display functions:

func display(child: Any) {
// this should never get called
print(child)
}
func display(child: Person) {
print(child)
}
func display(child: Address) {
print(child)
}

In above case it is always invoking `func display(child: Any)`, however I
want it to invoke the functions with specific parameter. Is there any way
to achieve this without type casting?:

Off-course this will work:

newOrderMirror.children.forEach {
if let bs = $0.value as? Person {
display(child: bs)
} else if let addr = $0.value as? Address {
display(child: addr)
}
display(child: $0.value)
}

Is there any other elegant way to achieve the desired behavior without
using `if-let + typecasting`?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Drawing boxes around each digit entered in UITextField (Number Pad)

2019-02-09 Thread Devarshi Kulshreshtha
To be more specific I am trying to implement OTP field as a single text
field. I was trying to plot 6 boxes in a field, so that user can enter one
digit in each box.

On Sunday, February 10, 2019, Gary L. Wade 
wrote:

> Rather than using a UITextField and guessing where things are, look at
> UITextView and its underlying components to know where each character
> actually is and how to coordinate your drawing with the drawing of each
> grapheme.  If you only want to draw the boxes when editing, you could
> instead provide your own field editor that does the same thing, and drawing
> when not editing would follow the non-boxed method.
> --
> Gary L. Wade
> http://www.garywade.com/
>
> On Feb 9, 2019, at 12:36 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> I am trying to draw boxes around each digit entered by a user in
> UITextField for which keyboard type is - Number Pad.
>
> To simplify the problem statement I assumed that each of the digits (0 to
> 9) will have same bounding box for its glyph, which I obtained using below
> code:
>
> func getGlyphBoundingRect() -> CGRect? {
>guard let font = font else {
>return nil
>}
>// As of now taking 8 as base digit
>var unichars = [UniChar]("8".utf16)
>var glyphs = [CGGlyph](repeating: 0, count: unichars.count)
>let gotGlyphs = CTFontGetGlyphsForCharacters(font, &unichars,
> &glyphs, unichars.count)
>if gotGlyphs {
>let cgpath = CTFontCreatePathForGlyph(font, glyphs[0], nil)!
>let path = UIBezierPath(cgPath: cgpath)
>return path.cgPath.boundingBoxOfPath
>}
>return nil
>}
>
> I am drawing each bounding box thus obtained using below code:
>
> func configure() {
>guard let boundingRect = getGlyphBoundingRect() else {
>return
>}
>for i in 0.. the box
>var box = boundingRect
>box.origin.x = (CGFloat(i) * boundingRect.width)
>let shapeLayer = CAShapeLayer()
>shapeLayer.frame = box
>shapeLayer.borderWidth = 1.0
>shapeLayer.borderColor = UIColor.orange.cgColor
>layer.addSublayer(shapeLayer)
>}
>}
>
> Now problem is -  if I am entering digits - 8,8,8 in the text field then
> for first occurrence of digit the bounding box drawn is aligned, however
> for second occurrence of same digit the bounding box appears a bit offset
> (by negative x), the offset value (in negative x) increases for subsequent
> occurrences of same digit.
>
> I tried to solve the problem by setting NSAttributedString.Key.kern to 0,
> however it did not change the behavior.
>
> Am I missing any important property in X axis from the calculation due to
> which I am unable to get properly aligned bounding box over each digit?
> Please suggest.
>
> --
> Thanks,
>
> Devarshi
>
>
>

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Drawing boxes around each digit entered in UITextField (Number Pad)

2019-02-09 Thread Devarshi Kulshreshtha
I am trying to draw boxes around each digit entered by a user in
UITextField for which keyboard type is - Number Pad.

To simplify the problem statement I assumed that each of the digits (0 to
9) will have same bounding box for its glyph, which I obtained using below
code:

func getGlyphBoundingRect() -> CGRect? {
guard let font = font else {
return nil
}
// As of now taking 8 as base digit
var unichars = [UniChar]("8".utf16)
var glyphs = [CGGlyph](repeating: 0, count: unichars.count)
let gotGlyphs = CTFontGetGlyphsForCharacters(font, &unichars,
&glyphs, unichars.count)
if gotGlyphs {
let cgpath = CTFontCreatePathForGlyph(font, glyphs[0], nil)!
let path = UIBezierPath(cgPath: cgpath)
return path.cgPath.boundingBoxOfPath
}
return nil
}

I am drawing each bounding box thus obtained using below code:

func configure() {
guard let boundingRect = getGlyphBoundingRect() else {
return
}
for i in 0..https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


SFSpeechRecognizer - recognitionTaskWithRequest - result not found

2018-05-11 Thread Devarshi Kulshreshtha
I am executing SpeakToMe code (
https://developer.apple.com/library/content/samplecode/SpeakToMe/Introduction/Intro.html
)
provided by apple on an iPad.

Most of the time it works fine, however sometimes it does not recognize
speech by user, below is the part of code which does not work as expected
in such scenarios:

recognitionTask = speechRecognizer.recognitionTask(with:
recognitionRequest) { result, error in
var isFinal = false

if let result = result {
self.textView.text =
result.bestTranscription.formattedString
isFinal = result.isFinal
}

if error != nil || isFinal {
self.audioEngine.stop()
inputNode.removeTap(onBus: 0)

self.recognitionRequest = nil
self.recognitionTask = nil

self.recordButton.isEnabled = true
self.recordButton.setTitle("Start Recording", for: [])
}
}

In above code following error is obtained:

SiriCoreSiriConnectionErrorDomain - code 4

Also I noticed that Siri stops recognising speech by user, when the same
behavior fails in the app. In order to make it work I have to restart the
device.

Any ideas on what could be wrong and how to resolve it?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Force portrait orientation programmatically

2018-04-17 Thread Devarshi Kulshreshtha
In our app we are supporting both orientations, however on selection of one
option we have to force user to remain only in portrait mode on all the
screens until he toggles it. So far we have found only this workable
solution:

[[UIDevice currentDevice] setValue:@(UIInterfaceOrientationLandscapeLeft)
forKey:@"orientation"];
[UINavigationController attemptRotationToDeviceOrientation];

Reference link: https://stackoverflow.com/a/26358192

The other solution which we tried is - returning NO from -shouldAutorotate
delegate. However the problem with this approach is that the delegate is
only called on currently displayed view controller not on previous view
controllers which might be behind it on navigation stack (or is presenting
view controller), hence only currently visible view controller starts
appearing in portrait mode, while previously displayed remain in landscape
mode.

I have two questions now:

Q1: Can our app be rejected from app store if we use the workable solution,
since we are trying to use the 'internal thing'?

Q2: What is the best approach to force set the orientation in app, at
runtime, say on tap of a button?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


UITabBarItem selection Voice over speaks number apart from accessibility label,value

2018-04-05 Thread Devarshi Kulshreshtha
I am programmatically assigning bar button items to  UITabBar using below
code:

-(void)setupTabs {
UIImage *icon1 = [[UIImage imageNamed:@"Icon1"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UITabBarItem *option1 = [[UITabBarItem alloc] initWithTitle:@"Option1"
image: icon1 selectedImage: icon1];

UIImage *icon2 = [[UIImage imageNamed:@"Icon2"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UITabBarItem *option2 = [[UITabBarItem alloc] initWithTitle:@"Option2"
image: icon2 selectedImage: icon2];

UIImage *icon3 = [[UIImage imageNamed:@"Icon3"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UITabBarItem *option3 = [[UITabBarItem alloc] initWithTitle:@"Option3"
image: icon3 selectedImage: icon3];

UIImage *icon4 = [[UIImage imageNamed:@"Icon4"]
imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UITabBarItem *option4 = [[UITabBarItem alloc] initWithTitle:@"Option4"
image: icon4 selectedImage: icon4];

self.tabBar.items = @[option1, option2, option3, option4];
}

Problem is - when I am tapping on respective tab bar item after enabling
Accessibility - Voice Over it is stating the tab bar title as well as
number 104 for first tab, 204 for second tab and so on.

I have tried explicitly setting the accessibilityValue, accessibilityLabel,
etc for items but it is always speaking the number after title.

Any ideas on how to stop voice over from speaking that number after title?

Thanks



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: CBPeripheralManager state unsupported Mac OS 10.12.6

2018-02-05 Thread Devarshi Kulshreshtha
My macbook is - MacBook Pro (13-inch, 2017)
System Information shows -
Bluetooth Low Energy Supported: Yes
LMP Version: 4.2 (0x8)

I know that if it shows a version of '0x6' or greater, BT 4.0 is supported.
However for some reasons I am getting state as unknown in the delegate.


On Tue, Feb 6, 2018 at 2:07 AM, Saagar Jha  wrote:

> What Mac are you using? Are you sure your Mac supports Bluetooth LE (I’m
> sure you already know this, but I just wanted to make sure)?
>
> Saagar Jha
>
> On Feb 5, 2018, at 05:25, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> I am trying to turn my macbook into BLE by using below code:
>
> var peripheralManager: CBPeripheralManager!
> let uuid = "A6C4C5FA-A8DD-4BA1-B9A8-A240584F02D3"
>
> let options = [CBCentralManagerOptionShowPowerAlertKey:0]
> manager = CBPeripheralManager(delegate: self, queue: nil, options: options)
>
> For some reasons peripheral state being received in below delegate is
> unsupported :
>
> func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
>if peripheral.state == .poweredOn {
>let dataToBeAdvertised:[String: [AnyObject]] =
> [CBAdvertisementDataServiceUUIDsKey : [CBUUID(string: uuid)]]
>peripheralManager.startAdvertising(dataToBeAdvertised)
>}
> }
>
> Any ideas on what could be the issue?
>
> --
> Thanks,
>
> Devarshi
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com
>
> This email sent to saa...@saagarjha.com
>
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


CBPeripheralManager state unsupported Mac OS 10.12.6

2018-02-05 Thread Devarshi Kulshreshtha
I am trying to turn my macbook into BLE by using below code:

var peripheralManager: CBPeripheralManager!
let uuid = "A6C4C5FA-A8DD-4BA1-B9A8-A240584F02D3"

let options = [CBCentralManagerOptionShowPowerAlertKey:0]
manager = CBPeripheralManager(delegate: self, queue: nil, options: options)

For some reasons peripheral state being received in below delegate is
unsupported :

func peripheralManagerDidUpdateState(_ peripheral: CBPeripheralManager) {
if peripheral.state == .poweredOn {
let dataToBeAdvertised:[String: [AnyObject]] =
[CBAdvertisementDataServiceUUIDsKey : [CBUUID(string: uuid)]]
peripheralManager.startAdvertising(dataToBeAdvertised)
}
}

Any ideas on what could be the issue?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


dequeueReusableCellWithIdentifier bad performance in case of less number of cells?

2018-01-10 Thread Devarshi Kulshreshtha
I had a discussion with my colleagues regarding use
of dequeueReusableCellWithIdentifier, few of them are under assumption that
if there are less number of cells it is better to directly alloc init a
UITableViewCell in place of using dequeueReusableCellWithIdentifier. They
are saying that since at a time almost all the cells will be displayed
there is no need to use dequeueReusableCellWithIdentifier because it
degrades performance in comparison to alloc init, in such scenarios. My
understanding is that there is no any performance cost as such and behind
the scenes dequeueReusableCellWithIdentifier is doing the same thing
(allocating and initializing) if a cell cannot be reused.

Is there any way I can compare the performance of using
dequeueReusableCellWithIdentifier versus using directly alloc init and
share with them to come to a conclusion? Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


In app purchase + redeem points as gift vouchers

2017-07-24 Thread Devarshi Kulshreshtha
We are developing a multiplayer game in which user has to buy some credit
point through in app purchase, then he can multiply those points by winning
multiplayer challenges with friends. On reaching a certain level of points,
he can reward himself by re-deeming gift vouchers (amazon, ebay, etc)
through those points. Does apple allow this type of game structure? Please
suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


MKMapView hybrid mode app hang problem

2017-01-19 Thread Devarshi Kulshreshtha
I have MKMapView on layout, if I enable Standard Mode and quickly perform
basic operations on it such as - zoom - in / out, pan it works fine but if
I perform same operations on MKMapView with hybridFlyover mode enabled CPU
utilisation reaches 100% and my app hangs.

Any ideas on how can resolve it?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Implementing own text prediction on UITextField

2016-09-29 Thread Devarshi Kulshreshtha
Currently when we type on a text field it shows text prediction over
keyboard on a bar, is there any way to populate the same with say a
dictionary, or a plist, etc. Basically populating it using own data source
rather than system data source.

Any ideas guys?

Thanks in advance.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Launching iOS 10 supported build using Xcode 7

2016-09-09 Thread Devarshi Kulshreshtha
We have a thoroughly tested build on iOS9 using Xcode 7 swift 2.2, we are
planning to release it on 16th of this month, since iOS10 will be released
on 13th  wanted to know that can we still release the build (iOS10
compatible) using Xcode 7 without upgrading it to swift 2.3?

Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Could not cast value of type 'Medication.Nurse' to 'MedicationTests.Nurse'

2016-08-22 Thread Devarshi Kulshreshtha
Found answer over here: https://forums.developer.apple.com/thread/11342

On Mon, Aug 22, 2016 at 2:41 PM, Devarshi Kulshreshtha <
devarshi.bluec...@gmail.com> wrote:

> I am making an app with name - "Medication", in which I am trying to
> implement unit test cases for certain operations on my managed objects.
>
> 
> Here is my entity:
>
> Entity name: Nurse
> attribute 1: email
> attribute 2: password
> relationship: patient
>
> In model editor by default it is showing Class as 'Nurse' and Module as
> 'Current Product Module'
>
> 
> Here is - Nurse+CoreDataProperties.swift class
>
> import Foundation
> import CoreData
>
> extension Nurse {
>
> @NSManaged var email: String?
> @NSManaged var password: String?
> @NSManaged var patient: NSSet?
>
> }
>
> 
> Here is - Nurse.swift class
>
> class Nurse: NSManagedObject {
> // adding nurse to local db
> class func addNurse(withEmail email: String, password: String,
> inManagedObjectContext managedObjectContext: NSManagedObjectContext) ->
> NSError? {
> var insertError : NSError? = nil
>
> // Check if it is a duplicate entry
> if isDuplicate(email: email, inManagedObjectContext:
> managedObjectContext) {
> // is duplicate
> let userInfo: [NSObject : AnyObject] =
> [NSLocalizedDescriptionKey :  NSLocalizedString("Duplicate Nurse!", value:
> "Nurse with same email already exists.", comment: "")]
> insertError = NSError(domain: 
> CoreDataCustomErrorCodes.DuplicateRecord.domain,
> code: CoreDataCustomErrorCodes.DuplicateRecord.rawValue, userInfo:
> userInfo)
> }
> else {
> // email does not exist
> let newNurse = NSEntityDescription.
> insertNewObjectForEntityForName(String(self), inManagedObjectContext:
> managedObjectContext) as! Nurse
> newNurse.email = email
> newNurse.password = password
>
> do {
> try managedObjectContext.save()
> } catch {
> let error = error as NSError
> print("\(error), \(error.userInfo)")
> insertError = error
> }
> }
>
> return insertError
> }
> }
>
> 
> Here is - NurseTests.swift
>
> import XCTest
> import CoreData
> @testable import Medication
>
> class NurseTests: XCTestCase {
> var managedObjectContext: NSManagedObjectContext?
>
> //MARK: Overriden methods
> override func setUp() {
> super.setUp()
> // Put setup code here. This method is called before the
> invocation of each test method in the class.
> if managedObjectContext == nil {
> managedObjectContext = setUpInMemoryManagedObjectContext()
> }
> }
>
> override func tearDown() {
> // Put teardown code here. This method is called after the
> invocation of each test method in the class.
> super.tearDown()
> }
>
> //MARK: Testing functions defined in Nurse.swift
> // testing : class func addNurse(withEmail email: String, password:
> String, inManagedObjectContext managedObjectContext:
> NSManagedObjectContext) -> NSError?
> func testAddNurse() {
> let nurseEmail = "cl...@gmail.com"
> let nursePassword = "clara"
>
> let error = Nurse.addNurse(withEmail: nurseEmail, password:
> nursePassword, inManagedObjectContext: managedObjectContext!)
> XCTAssertNil(error, "There should not be any error while adding a
> nurse")
> }
>
> }
>
> 
> Problem is when I am trying to execute the test case it is showing me this
> error in Xcode console:
>
> Could not cast value of type 'Medication.Nurse' (0x7ff69284a120) to
> 'MedicationTests.Nurse' (0x111ed8388).
>
> And crashing at this line:
>
> let newNurse = 
> NSEntityDescription.insertNewObjectForEntityForName(String(self),
> inManagedObjectContext: managedObjectContext) as! Nurse
>
> Any ideas guys?
>
> --
> Thanks,
>
> Devarshi
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Could not cast value of type 'Medication.Nurse' to 'MedicationTests.Nurse'

2016-08-22 Thread Devarshi Kulshreshtha
I am making an app with name - "Medication", in which I am trying to
implement unit test cases for certain operations on my managed objects.


Here is my entity:

Entity name: Nurse
attribute 1: email
attribute 2: password
relationship: patient

In model editor by default it is showing Class as 'Nurse' and Module as
'Current Product Module'


Here is - Nurse+CoreDataProperties.swift class

import Foundation
import CoreData

extension Nurse {

@NSManaged var email: String?
@NSManaged var password: String?
@NSManaged var patient: NSSet?

}


Here is - Nurse.swift class

class Nurse: NSManagedObject {
// adding nurse to local db
class func addNurse(withEmail email: String, password: String,
inManagedObjectContext managedObjectContext: NSManagedObjectContext) ->
NSError? {
var insertError : NSError? = nil

// Check if it is a duplicate entry
if isDuplicate(email: email, inManagedObjectContext:
managedObjectContext) {
// is duplicate
let userInfo: [NSObject : AnyObject] =
[NSLocalizedDescriptionKey :  NSLocalizedString("Duplicate Nurse!", value:
"Nurse with same email already exists.", comment: "")]
insertError = NSError(domain:
CoreDataCustomErrorCodes.DuplicateRecord.domain, code:
CoreDataCustomErrorCodes.DuplicateRecord.rawValue, userInfo: userInfo)
}
else {
// email does not exist
let newNurse =
NSEntityDescription.insertNewObjectForEntityForName(String(self),
inManagedObjectContext: managedObjectContext) as! Nurse
newNurse.email = email
newNurse.password = password

do {
try managedObjectContext.save()
} catch {
let error = error as NSError
print("\(error), \(error.userInfo)")
insertError = error
}
}

return insertError
}
}


Here is - NurseTests.swift

import XCTest
import CoreData
@testable import Medication

class NurseTests: XCTestCase {
var managedObjectContext: NSManagedObjectContext?

//MARK: Overriden methods
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation
of each test method in the class.
if managedObjectContext == nil {
managedObjectContext = setUpInMemoryManagedObjectContext()
}
}

override func tearDown() {
// Put teardown code here. This method is called after the
invocation of each test method in the class.
super.tearDown()
}

//MARK: Testing functions defined in Nurse.swift
// testing : class func addNurse(withEmail email: String, password:
String, inManagedObjectContext managedObjectContext:
NSManagedObjectContext) -> NSError?
func testAddNurse() {
let nurseEmail = "cl...@gmail.com"
let nursePassword = "clara"

let error = Nurse.addNurse(withEmail: nurseEmail, password:
nursePassword, inManagedObjectContext: managedObjectContext!)
XCTAssertNil(error, "There should not be any error while adding a
nurse")
}

}


Problem is when I am trying to execute the test case it is showing me this
error in Xcode console:

Could not cast value of type 'Medication.Nurse' (0x7ff69284a120) to
'MedicationTests.Nurse' (0x111ed8388).

And crashing at this line:

let newNurse =
NSEntityDescription.insertNewObjectForEntityForName(String(self),
inManagedObjectContext: managedObjectContext) as! Nurse

Any ideas guys?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Using protocol extension to dismiss keyboard on outside tap

2016-04-18 Thread Devarshi Kulshreshtha
Thanks, I ended doing exactly what you suggested.

On Mon, Apr 18, 2016 at 10:41 PM, Quincey Morris <
quinceymor...@rivergatesoftware.com> wrote:

> On Apr 18, 2016, at 08:48 , Alex Kac  wrote:
>
>
> Protocol extensions are Swift only - not ObjC compatible I believe.
>
>
> You’re right, and I don’t see any direct way of getting around. Alternate
> solutions:
>
> 1. If the “shared” code really is this short:
>
> private func configureToDismissKeyboard() {
>
>let tapGesture = UITapGestureRecognizer(target: self,
> action: "hideKeyboard")
>tapGesture.cancelsTouchesInView = true
>form.addGestureRecognizer(tapGesture)
>}
>
>func hideKeyboard() {
>form.endEditing(true)
>}
>
>
> then I don’t see the value in going to any trouble to factor it out of
> multiple classes. I’d recommend just duplicating it in each view
> controller. (Further, ‘configureToDismissKeyboard’ doesn’t really need to
> be a function. Its 3-line body could easily be written inline in
> viewDidLoad.)
>
> Swift tends to produce a desire for over-generalization. In cases where
> the simple approach is a better use of developer time, the desire should be
> resisted. :)
>
> 2. If the actual code is more complicated, I think the problem can be
> solved by a simple “transfer” method in each class:
>
> func hideKeyboard () { doHideKeyboard () }
>
>
> where ‘doHideKeyboard’ is in the protocol and extension in place of
> ‘hideKeyboard’.
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Using protocol extension to dismiss keyboard on outside tap

2016-04-18 Thread Devarshi Kulshreshtha
On doing that it started showing me this error:

Type `MyViewController` does not conform to protocol
`DismissKeyboardOnOutsideTap`.

On code suggestion it showed:

Fix-it: Candidate is not `objc` but protocol requires it

On Mon, Apr 18, 2016 at 1:59 PM, Quincey Morris <
quinceymor...@rivergatesoftware.com> wrote:

> On Apr 18, 2016, at 01:07 , Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
>
>extension DismissKeyboardOnOutsideTap {
>func configureToDismissKeyboard() {
>…
>}
>
>func hideKeyboard() {
>…
>}
>
>}
>
>
> I think the problem is that your methods are Swift functions, and so have
> mangled names. It should be enough to declare protocol as an Obj-C protocol:
>
> @objc protocol DismissKeyboardOnOutsideTap {
>…
>}
>
>
> Since all the classes involved are Obj-C classes, I don’t think it has to
> be any more complicated than this.
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Using protocol extension to dismiss keyboard on outside tap

2016-04-18 Thread Devarshi Kulshreshtha
In my project I have few view controllers which are subclasses of
UITableViewController, UIViewController, on each I want to implement this
behavior:

> When user taps outside of a text field it should dismiss the keyboard
which was visible when user tapped inside it.

I can easily implement it by defining a tap gesture recognizer and
associating a selector to dismiss the keyboard:

class MyViewController {

override func viewDidLoad() {
super.viewDidLoad()
configureToDismissKeyboard()
}

private func configureToDismissKeyboard() {
let tapGesture = UITapGestureRecognizer(target: self, action:
"hideKeyboard")
tapGesture.cancelsTouchesInView = true
form.addGestureRecognizer(tapGesture)
}

func hideKeyboard() {
form.endEditing(true)
}
}

Since I have to implement same behavior in multiple view controllers, I am
trying to identify a way to avoid using repetitive code in multiple classes.

One option for me is to define a `BaseViewController`, which is subclass of
`UIViewController`, with all above methods defined within it and then
subclass each of my view controller to `BaseViewController`. The problem
with this approach is that I need to define two `BaseViewController`s one
for `UIViewController` and one for `UITableViewController` since I am using
subclasses of both.

The other option which I am trying to use is - `Protocol-Oriented
Programming`. So I defined a protocol:

protocol DismissKeyboardOnOutsideTap {
var backgroundView: UIView! { get }
func configureToDismissKeyboard()
func hideKeyboard()
}

Then defined its extension:

extension DismissKeyboardOnOutsideTap {
func configureToDismissKeyboard() {
if let this = self as? AnyObject {
let tapGesture = UITapGestureRecognizer(target: this,
action: "hideKeyboard")
tapGesture.cancelsTouchesInView = true
backgroundView.addGestureRecognizer(tapGesture)
}

}

func hideKeyboard() {
backgroundView.endEditing(true)
}

}

In my view controller I confirmed to the protocol:

class MyViewController: UITableViewController,
DismissKeyboardOnOutsideTap {

var backgroundView: UIView!

override func viewDidLoad() {
super.viewDidLoad()

// configuring background view to dismiss keyboard on outside
tap
backgroundView = self.tableView
configureToDismissKeyboard()
}
}

Problem is - above code is crashing with exception:

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[MyProject.MyViewController hideKeyboard]: unrecognized selector
sent to instance 0x7f88c1e5d700'

To avoid this crash I need to redefine `hideKeyboard` function within
`MyViewController`class, which is defeating my purpose of avoiding
repetitive code :(

Please suggest if I am doing any thing wrong over here or is there any
better way to implement my requirement.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to comply to Disability Discrimination Act of 1995 while developing an iOS app

2016-04-17 Thread Devarshi Kulshreshtha
We have a requirement from our UK client in which he wants us to comply to
Disability Discrimination Act of 1995 (
https://en.wikipedia.org/wiki/Disability_Discrimination_Act_1995) while
developing the iOS app. I tried to search about it on Internet but most of
the information is available on compliance by websites. I think that it
might be related to supporting accessibility in our app as stated in this
link: Accessibility on iOS (https://developer.apple.com/accessibility/ios/).

Can the community members confirm if my understanding is right?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security has blocked a cleartext HTTP for a local IP

2015-10-16 Thread Devarshi Kulshreshtha
On Fri, Oct 16, 2015 at 1:59 AM, Jens Alfke  wrote:

> What’s the exact URL that failed to load?
>
> —Jens


http://10.32.27.12/api/Students

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security has blocked a cleartext HTTP for a local IP

2015-10-16 Thread Devarshi Kulshreshtha
> I read on some blogposts that ios9 GM did not support IP addresses for
> ATS. Do not know if this has changed.
>
>
I am testing it on iOS9 simulator :-/


> On Thu, Oct 15, 2015 at 9:06 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
>> Our webservices are hosted in some local IP, to bypass the App Transport
>> Security I added this as dictionary for NSAppTransportSecurity key in my
>> info.plist file:
>>
>>
>> 
>> NSAllowsArbitraryLoads
>> 
>> NSExceptionDomains
>> 
>> localhost
>> 
>> NSExceptionAllowsInsecureHTTPLoads
>> 
>> 
>> 10.32.27.12
>> 
>> NSExceptionAllowsInsecureHTTPLoads
>> 
>> 
>> 
>> 
>>
>> but for some reasons I am still getting this error message:
>>
>> App Transport Security has blocked a cleartext HTTP (http://) resource
>> load
>> since it is insecure. Temporary exceptions can be configured via your
>> app's
>> Info.plist file
>>
>> Any ideas?
>>
>> --
>> Thanks,
>>
>> Devarshi
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/xhruso00%40gmail.com
>>
>> This email sent to xhrus...@gmail.com
>
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: App Transport Security has blocked a cleartext HTTP for a local IP

2015-10-16 Thread Devarshi Kulshreshtha
 What happens if you only use this:

>
> NSAllowsArbitraryLoads
> 
>
> ??
>

Then it works as expected.. but that is not the preferred approach ..
because we are pointing to local ip just for testing purpose, in future we
will be pointing it to a public IP (probably https) and if we miss to
update the info.plist then it will be security vulnerability.. right?


>
> On Oct 15, 2015, at 3:56 PM, Marek Hrušovský wrote:
>
> > I read on some blogposts that ios9 GM did not support IP addresses for
> ATS.
> > Do not know if this has changed.
> >
> > On Thu, Oct 15, 2015 at 9:06 PM, Devarshi Kulshreshtha <
> > devarshi.bluec...@gmail.com> wrote:
> >
> >> Our webservices are hosted in some local IP, to bypass the App Transport
> >> Security I added this as dictionary for NSAppTransportSecurity key in my
> >> info.plist file:
> >>
> >>
> >> 
> >> NSAllowsArbitraryLoads
> >> 
> >> NSExceptionDomains
> >> 
> >> localhost
> >> 
> >> NSExceptionAllowsInsecureHTTPLoads
> >> 
> >> 
> >> 10.32.27.12
> >> 
> >> NSExceptionAllowsInsecureHTTPLoads
> >> 
> >> 
> >> 
> >> 
> >>
> >> but for some reasons I am still getting this error message:
> >>
> >> App Transport Security has blocked a cleartext HTTP (http://) resource
> >> load
> >> since it is insecure. Temporary exceptions can be configured via your
> app's
> >> Info.plist file
> >>
> >> Any ideas?
> >>
> >> --
> >> Thanks,
> >>
> >> Devarshi
> >> ___
> >>
> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >>
> >> Please do not post admin requests or moderator comments to the list.
> >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >>
> >> Help/Unsubscribe/Update your Subscription:
> >> https://lists.apple.com/mailman/options/cocoa-dev/xhruso00%40gmail.com
> >>
> >> This email sent to xhrus...@gmail.com
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> >
> > This email sent to z...@mac.com
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

App Transport Security has blocked a cleartext HTTP for a local IP

2015-10-15 Thread Devarshi Kulshreshtha
Our webservices are hosted in some local IP, to bypass the App Transport
Security I added this as dictionary for NSAppTransportSecurity key in my
info.plist file:



NSAllowsArbitraryLoads

NSExceptionDomains

localhost

NSExceptionAllowsInsecureHTTPLoads


10.32.27.12

NSExceptionAllowsInsecureHTTPLoads





but for some reasons I am still getting this error message:

App Transport Security has blocked a cleartext HTTP (http://) resource load
since it is insecure. Temporary exceptions can be configured via your app's
Info.plist file

Any ideas?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Data not retained in document based core data app with cocoa bindings

2015-10-11 Thread Devarshi Kulshreshtha
Thank you Richard, Jerry.

I tried this binding:
self.view.window.windowController.document.managedObjectContext
and verified by opening the saved xml document in TextEdit, it showed saved
info :) but when I am trying to open it using the created app,
'DocumentSample' in my case, it is not showing any data in opened window.

Looking for more clues :-|

On Sun, Oct 11, 2015 at 11:20 AM, Richard Charles 
wrote:

>
> > On Oct 10, 2015, at 12:34 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
> >
> > I am sure that I am missing something over here, looking for guidance.
>
> As instructed by Jerry delete the Document from your storyboard.
>
> Courtesy of Apple and Mike Swan bind the array controller parameters
> managed object context to the view controller with a model key path of
>
> self.view.window.windowController.document.managedObjectContext
>
>
> http://stackoverflow.com/questions/28184218/what-is-the-new-way-of-binding-an-nsarraycontroller-to-the-managed-object-contex
>
> Save the document as an xml file. Open with TextEdit and verify that the
> model data has been saved to disk. The data will be identified with
> something like id="z103".
>
> Unfortunately when you reopen the document the model data does not display
> in the table view, so there are more issues to be addressed.
>
> --Richard Charles
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Data not retained in document based core data app with cocoa bindings

2015-10-10 Thread Devarshi Kulshreshtha
I am trying to make a simple document based core data app using cocoa
bindings by following below steps:

*Step 1: *Selected the default template for a document based mac os x app
with core data as enabled

*Step 2:* It generated below files -

*a*. AppDelegate.swift
*b*. ViewController.swift
*c.* Document.swift
*d*. Main.storyboard
*e*. Document.xcdatamodel, etc

*Step 3:* Added an entity - MyColorPalette with an attribute - myColorName
of type string

*Step 4:* In Main.storyboard added a table view over view controller

*Step 5:* Dragged an 'ArrayController' object from library onto
ViewControllerScene

*Step 6:* Dragged an 'NSObject' object from library onto ViewControllerScene

*Step 7:* Changed class of 'NSObject' object to 'Document'

*Step 8:* Updated entity of ArrayController as - MyColorPalette and
managedObject as - Document.managedObjectContext

*Step 9:* Selected table view column and performed its value binding with
arrayController, controller key as - arrangedObjects and modelKeyPath
as myColorName

*Step 10:* Added two buttons - 'Add' and 'Delete', mapped respective 'add:'
and 'remove:' actions with 'ArrayController' object

Now when I am running the app and trying to add or delete it is working
perfectly, but when I am trying to save the document and then re-open it,
it is not showing the previously saved information.

I am sure that I am missing something over here, looking for guidance.

Here is the link to its source code at github:
https://github.com/Daemon-Devarshi/DocumentSample

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Converted mov to mp4, output file not working in default android video player

2015-09-04 Thread Devarshi Kulshreshtha
I used below code to convert an mov file to mp4 in my mac os x app:

- (IBAction)convertAction:(id)sender {

NSString *sampleMov = [@"~/Desktop/sample_mov.mov"
stringByExpandingTildeInPath];

AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:[NSURL
fileURLWithPath:sampleMov]
options:nil];

  //  NSArray *compatiblePresets = [AVAssetExportSession
exportPresetsCompatibleWithAsset:avAsset];

AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough];

NSString *videoPath = [@"~/Desktop/sample_mp4_movie.mp4"
stringByExpandingTildeInPath];

exportSession.outputURL = [NSURL fileURLWithPath:videoPath];

NSLog(@"videopath of your mp4 file = %@",videoPath);  // PATH OF YOUR
.mp4 FILE

exportSession.outputFileType = AVFileTypeMPEG4;

 [exportSession exportAsynchronouslyWithCompletionHandler:^{

switch ([exportSession status]) {

 case AVAssetExportSessionStatusFailed:

NSLog(@"Export failed: %@", [[exportSession error]
localizedDescription]);

  break;

  case AVAssetExportSessionStatusCancelled:

NSLog(@"Export canceled");

   break;

  default: break;

}}];

}
Though it has successfully converted the file, the same file when sent to
an android device could not be played :(

Any ideas?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Any native API for credit/ debit card info scan

2015-08-26 Thread Devarshi Kulshreshtha
Card.io is awesome, only problem is - it does not extract user's name from
card :(

On Wed, Aug 26, 2015 at 1:12 PM, Jonathan Hull  wrote:

> I don’t think there is a way to access this functionality in the system
> frameworks, but we have had good results with Card.io:
> https://www.card.io
>
> Thanks,
> Jon
>
>
> > On Aug 26, 2015, at 12:23 AM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
> >
> > In iOS 8, Apple has a new feature in Safari that allows users to scan a
> > credit card with the device’s camera rather than manually entering the
> > number when making a purchase online.
> >
> > Does it also expose native APIs for the same to be used by developer
> > community as well? Any ideas?
> >
> > --
> > Thanks,
> >
> > Devarshi
> > ___
> >
> > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> >
> > Please do not post admin requests or moderator comments to the list.
> > Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> >
> > Help/Unsubscribe/Update your Subscription:
> > https://lists.apple.com/mailman/options/cocoa-dev/jhull%40gbis.com
> >
> > This email sent to jh...@gbis.com
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Any native API for credit/ debit card info scan

2015-08-26 Thread Devarshi Kulshreshtha
In iOS 8, Apple has a new feature in Safari that allows users to scan a
credit card with the device’s camera rather than manually entering the
number when making a purchase online.

Does it also expose native APIs for the same to be used by developer
community as well? Any ideas?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Will iOS app accepted on App Store if 80% of UI is rendered on UIWebView and 20% being native OCR

2015-08-19 Thread Devarshi Kulshreshtha
I have a mobile website which at high level provides these functionalities:

 1. Sign-in
 2. Sign-up
 3. Few forms where user can fill his additional details
 4. Providing some capabilities to user based on information provided by him

Now I want to integrate OCR capabilities such as:

 1. ID card scan
 2. Debit card scan
 3. Void check scan

So that some of the forms can be automatically filled by information
extracted from these.

I am planning to make a native app in iOS consuming most of the forms, flow
from my mobile website by rendering respective weburls on webview, and
integrating vendor SDKs to provide OCR capabilities.

Will Apple accept my iOS app in App Store if I have 80% of flow, UI
rendered on UIWebView and remaining 20% being integration and use of native
vendor SDKs for OCR capabilities?


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Integrating touch Id with sign up-in process in client-server based app

2015-07-16 Thread Devarshi Kulshreshtha
Hi All,

I am working on an app in which user can perform registration and then can
login into it by entering his email id and password.

As per the new requirements client wants us to support touch Id
authentication during sign in process.

After reading through the documentation what I have understood is that - by
integrating touch id in the app, I can have two way authentication:

1. Validate user locally by using LAContext
2. Validate the user at server based on credentials entered by him

My question is - is there any way we can use touch ID to validate user at
server, say by sending and validating his biometric information at server?

Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

UIPageViewController not resizing its child view controllers on rotation

2015-06-30 Thread Devarshi Kulshreshtha
I am trying to use UIPageViewController with view controllers added to it,
problem is if I launch the app in portrait mode it appears perfectly like
this:

http://i.stack.imgur.com/ryT5d.png

but if I rotate the device to landscape mode it appears like this:

http://i.stack.imgur.com/GnuYH.png

Though pagination control has resized properly, view of added view
controller has not resized properly.

Below is the code which I have used to add respective view controller as
root view controller in AppDelegate:

pagesContainerViewController = [[RWPagesContainerViewController alloc]
initWithNibName:@"RWPagesContainerViewController" bundle:nil];
[pagesContainerViewController loadPaginationControlAtIndex:0];
self.window.rootViewController = pagesContainerViewController;

Here is the implementation of loadPaginationControlAtIndex method:

- (void)loadPaginationControlAtIndex:(RWPaginationView)viewIndex {
_pageController = [[UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:nil];

FirstViewController *firstViewController = [[FirstViewController
alloc] initWithNibName:@"FirstViewController" bundle:nil];
SecondViewController *secondViewController = [[SecondViewController
alloc] initWithNibName:@"SecondViewController" bundle:nil];
ThirdViewController *thirdViewController = [[ThirdViewController
alloc] initWithNibName:@"ThirdViewController" bundle:nil];

_subviewControllers = @[firstViewController, secondViewController,
thirdViewController];

[self.pageController
setViewControllers:@[_subviewControllers[viewIndex]]
direction:UIPageViewControllerNavigationDirectionForward animated:YES
completion:nil];

[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];

UIView *insertedView = self.pageController.view;
insertedView.translatesAutoresizingMaskIntoConstraints = NO;
self.view.translatesAutoresizingMaskIntoConstraints = NO;

[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"H:|[insertedView]|"

options:0

metrics:nil

views:NSDictionaryOfVariableBindings(insertedView)]];
[self.view addConstraints:[NSLayoutConstraint
constraintsWithVisualFormat:@"V:|[insertedView]|"

options:0

metrics:nil

views:NSDictionaryOfVariableBindings(insertedView)]];

[self.view layoutIfNeeded];

self.pageController.dataSource = self;
}

Am I missing anything? Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000000bbadbeef crash on UIWebview

2015-06-22 Thread Devarshi Kulshreshtha
Thanks Mike.. I will try that and check for memory leaks in my app

On Mon, Jun 22, 2015 at 2:38 PM, Mike Abdullah 
wrote:

> Have you experimented with passing something bigger than CGRectZero for
> the web view’s initial size? Maybe it’s freaking out over that.
>
> Some googling also suggests that the bbadbeef code can mean WebKit
> couldn’t allocate enough memory. Maybe you’re using too much memory in your
> app in total?
>
> > On 22 Jun 2015, at 09:21, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
> >
> > Here is my viewDidLoad method:
> >
> > EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xbbadbeef
> >
> > - (void)viewDidLoad {
> >[super viewDidLoad];
> >
> >[self setTitle:[self.parameters_ get:@"title"]];
> >whiteBGLayer = [[CALayer alloc] init];
> >[whiteBGLayer setBackgroundColor:[UIColor whiteColor].CGColor];
> >[self.view.layer addSublayer:whiteBGLayer];
> >
> >if ([self isWebView]) {
> >_webView = [[UIWebView alloc] initWithFrame:CGRectZero];
> >_webView.delegate = self;
> >_webView.allowsInlineMediaPlayback = YES;
> >_webView.mediaPlaybackRequiresUserAction = NO;
> >[self  checkWebsiteAuthentication];
> >[_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
> >NSString *encodedUrlString = [self
> > toAbsoluteUrlWithNSString:[self.parameters_ get:@"url"]];
> >NSURL *url = [NSURL URLWithString:encodedUrlString];
> >NSURLRequest *request = [NSURLRequest requestWithURL:url];
> >
> >_webView.frame = self.view.frame;
> >[_webView loadRequest:request];
> >[_webView setScalesPageToFit:YES];
> >_webView.scrollView.delegate = self;
> >
> >[self.view addSubview:_webView];
> >[_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
> >[self.view setNeedsUpdateConstraints];
> >} else {
> >self.view.backgroundColor = [UIColor whiteColor];
> >_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320,
> > 40)];
> >_label.text = @"content view";
> >[self.view addSubview:_label];
> >}
> >
> >if (someName isEqualToString:@“SomeName”]) {
> >UINib *nib = [UINib nibWithNibName:@XYYouTubePlayerContainerView"
> > bundle:nil];
> >self.youTubePlayerContainerView = [[nib instantiateWithOwner:self
> > options:nil] objectAtIndex:0];
> >self.youTubePlayerContainerView.hidden = YES;
> >[self.view addSubview:self.youTubePlayerContainerView];
> >
> >[[NSNotificationCenter defaultCenter] addObserver:self
> > selector:@selector
> > (dismissVideoPlayer)
> >
> > name:UIWindowDidBecomeHiddenNotification
> >   object:nil];
> >}
> >
> >
> > }
> >
> > For some reasons it is  at this line as reported by crashlytics:
> >
> > _webView = [[UIWebView alloc] initWithFrame:CGRectZero];
> >
> > Here is the stack-tace of crashed thread:
> >
> > Thread : Crashed: com.apple.root.utility-qos
> >
> > 0  JavaScriptCore 0x00018413c9e4 WTFCrash + 72
> >
> > 1  JavaScriptCore 0x00018413c9dc WTFCrash + 64
> >
> > 2  WebCore0x000190992504
> > WebRunLoopUnlock(__CFRunLoopObserver*, unsigned long, void*)
> >
> > 3  WebCore0x000190992dac WebThreadLock + 104
> >
> > 4  UIKit  0x000187449b2c -[UIWebView
> > _webViewCommonInitWithWebView:scalesPageToFit:] + 140
> >
> > 5  UIKit  0x00018729dc38 -[UIWebView
> > initWithFrame:] + 88
> >
> > 6  XYZ   0x0001002e0b60
> > -[XYContentViewController viewDidLoad] (XYContentViewController.m:43)
> >
> > 7  UIKit  0x000187074958 -[UIViewController
> > loadViewIfRequired] + 692
> >
> > 8  UIKit  0x000187074668 -[UIViewController
> > view] + 32
> >
> > 9  XYZ   0x000100032620
> -[XYModalViewController
> > setViewController:] (XYModalViewController.m:252)
> >
> > 10 XYZ   0x00010003279c
> -[XYModalViewController
> > pushModalController:] (XYModalViewController.m:260)
> >
> > 11 XYZ  

EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000000bbadbeef crash on UIWebview

2015-06-22 Thread Devarshi Kulshreshtha
Here is my viewDidLoad method:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xbbadbeef

- (void)viewDidLoad {
[super viewDidLoad];

[self setTitle:[self.parameters_ get:@"title"]];
whiteBGLayer = [[CALayer alloc] init];
[whiteBGLayer setBackgroundColor:[UIColor whiteColor].CGColor];
[self.view.layer addSublayer:whiteBGLayer];

if ([self isWebView]) {
_webView = [[UIWebView alloc] initWithFrame:CGRectZero];
_webView.delegate = self;
_webView.allowsInlineMediaPlayback = YES;
_webView.mediaPlaybackRequiresUserAction = NO;
[self  checkWebsiteAuthentication];
[_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
NSString *encodedUrlString = [self
 toAbsoluteUrlWithNSString:[self.parameters_ get:@"url"]];
NSURL *url = [NSURL URLWithString:encodedUrlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

_webView.frame = self.view.frame;
[_webView loadRequest:request];
[_webView setScalesPageToFit:YES];
_webView.scrollView.delegate = self;

[self.view addSubview:_webView];
[_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view setNeedsUpdateConstraints];
} else {
self.view.backgroundColor = [UIColor whiteColor];
_label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 320,
40)];
_label.text = @"content view";
[self.view addSubview:_label];
}

if (someName isEqualToString:@“SomeName”]) {
UINib *nib = [UINib nibWithNibName:@XYYouTubePlayerContainerView"
bundle:nil];
self.youTubePlayerContainerView = [[nib instantiateWithOwner:self
options:nil] objectAtIndex:0];
self.youTubePlayerContainerView.hidden = YES;
[self.view addSubview:self.youTubePlayerContainerView];

[[NSNotificationCenter defaultCenter] addObserver:self
 selector:@selector
(dismissVideoPlayer)

 name:UIWindowDidBecomeHiddenNotification
   object:nil];
}


}

For some reasons it is  at this line as reported by crashlytics:

_webView = [[UIWebView alloc] initWithFrame:CGRectZero];

Here is the stack-tace of crashed thread:

Thread : Crashed: com.apple.root.utility-qos

0  JavaScriptCore 0x00018413c9e4 WTFCrash + 72

1  JavaScriptCore 0x00018413c9dc WTFCrash + 64

2  WebCore0x000190992504
WebRunLoopUnlock(__CFRunLoopObserver*, unsigned long, void*)

3  WebCore0x000190992dac WebThreadLock + 104

4  UIKit  0x000187449b2c -[UIWebView
_webViewCommonInitWithWebView:scalesPageToFit:] + 140

5  UIKit  0x00018729dc38 -[UIWebView
initWithFrame:] + 88

6  XYZ   0x0001002e0b60
-[XYContentViewController viewDidLoad] (XYContentViewController.m:43)

7  UIKit  0x000187074958 -[UIViewController
loadViewIfRequired] + 692

8  UIKit  0x000187074668 -[UIViewController
view] + 32

9  XYZ   0x000100032620 -[XYModalViewController
setViewController:] (XYModalViewController.m:252)

10 XYZ   0x00010003279c -[XYModalViewController
pushModalController:] (XYModalViewController.m:260)

11 XYZ   0x000100038b14 -[XYViewController
presentModalController:] (XYViewController.m:426)

12 XYZ   0x0001002fc3d4 __57-[AppDelegate
application:didFinishLaunchingWithOptions:]_block_invoke451
(AppDelegate.m:590)

13 XYZ   0x0001002fc6c0 __57-[AppDelegate
application:didFinishLaunchingWithOptions:]_block_invoke499
(AppDelegate.m:619)

14 Foundation 0x000183672574 -[__NSObserver _doit:]
+ 320

15 CoreFoundation 0x00018280cddc
__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20

16 CoreFoundation 0x00018274b370 _CFXNotificationPost +
2060

17 Foundation 0x00018366f520 -[NSNotificationCenter
postNotificationName:object:userInfo:] + 72

18 XYZ   0x000100312a50
__44-[XYListingPriceHistoryCell getPriceAlerts:]_block_invoke_2
(XYListingPriceHistoryCell.m:77)

19 libdispatch.dylib  0x000193e75994
_dispatch_call_block_and_release + 24

20 libdispatch.dylib  0x000193e75954
_dispatch_client_callout + 16

21 libdispatch.dylib  0x000193e82780
_dispatch_root_queue_drain + 1848

22 libdispatch.dylib  0x000193e83c4c
_dispatch_worker_thread3 + 108

23 libsystem_pthread.dylib0x00019405522c _pthread_wqthread + 816


I am clueless please suggest.


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not pos

Re: Swift : iterating over NSArrayController arrangedObjects

2015-06-21 Thread Devarshi Kulshreshtha
Thanks for your help :)

I got it working using this:

for index in downloadingFilesArrayController.arrangedObjects as!
[AnyObject] {
}

On Sun, Jun 21, 2015 at 8:01 PM, Ken Thomases  wrote:

> On Jun 21, 2015, at 8:44 AM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> > I have an array controller which stores managed objects of entity
> > 'Student', I am trying to iterate over its content using below code:
> >
> > for (index, element) in downloadingFilesArrayController.arrangedObjects{
> >
> >   // want to do some useful things on element
> >
> > }
> >
> > for some reasons it is showing compilation error:
> >
> > 'Type AnyObject does not conform to protocol SequenceType'
> >
> > Any ideas on how can fix it?
>
> The problem is that the arrangedObjects property of NSArrayController is
> typed as "id", not "NSArray*".  Try casting it to an array:
>
> for (index, element) in downloadingFilesArrayController.arrangedObjects
> as! [AnyObject] {
> }
>
> Regards,
> Ken
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift : iterating over NSArrayController arrangedObjects

2015-06-21 Thread Devarshi Kulshreshtha
>
> You’re trying to iterate an array of something and put each element into a
> tuple of ( index, element ), that’s not going to work.
>

>> ok


>
>
> Either
>
> for element in downlaodFileArrayController.arrangedObects {}
>

>> Got compilation error: Type 'AnyObject' does not conform to protocol
'Sequence Type'


> or
>
> for (index, element ) in
> downloadingFilesArrayControler.arrangedObjects.enumerate() {}
>
>
>> Got compilation error: AnyObject does not have a member named 'enumerate'


> If you’re on Swift 1.2 I think it’s enumerate(
> downloadingFilesArrayController.arrangedObjects ) instead of the enumerate
> on the end.
>
> Can’t say the error message makes any sense to me however, not that the
> one I get in Xcode 7 makes much more sense.
>
> >> I am trying it on Xcode 7 only


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Swift : iterating over NSArrayController arrangedObjects

2015-06-21 Thread Devarshi Kulshreshtha
I have an array controller which stores managed objects of entity
'Student', I am trying to iterate over its content using below code:

for (index, element) in downloadingFilesArrayController.arrangedObjects{

   // want to do some useful things on element

}

for some reasons it is showing compilation error:

'Type AnyObject does not conform to protocol SequenceType'

Any ideas on how can fix it?
-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Keyboard notifications triggered unnecessarily upon showing UIAlertview on iOS8.3

2015-05-19 Thread Devarshi Kulshreshtha
Greetings!

We are observing unusual behaviour with respect to Keyboard willshow & will
hide notification on iOS 8.3.

The viewcontroler (listenig to keyboard notifications) has a textfiled and
upon clicking and upon tapping the submit button, the method first resigns
the first responder from textfield, and shows an alert to inform warning.
Everything works fine, it dismisses the keyboard and shows up the alert as
expected. (calls the UIKeyboardWillHideNotification method too).

However, on 8.3, after tapping OK/Cancel on Alertview delegate, it
dismisses the alert and it calls up UIKeyboardWillShowNotification &
UIKeyboardWillHideNotification respectively, though it was not supposed to
be called! This was not expected, as the keyboard was already dismissed
before dispalying the alert!

Here is the code snippet, that we are trying:

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification
object:nil];

}

- (IBAction)ShowAlert:(id)sender {

[self.TxtField resignFirstResponder];

 //This woudln't make any diff either :(
[self.view endEditing:YES];

  [self ShowAlertForTest];

}


-(void)ShowAlertForTest{

UIAlertView *theAlertView= [[UIAlertView alloc]initWithTitle:@"Title"

 message:@"msg"

delegate:self

   cancelButtonTitle:@"Cancel"

   otherButtonTitles:@"Yes",
nil];

   [theAlertView show];

}
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
 NSLog(@"buttonIndex = %ld",buttonIndex);
}

- (void)keyboardWillShow:(NSNotification *)aNotification
{
NSLog(@"keyboardWillShow");
}


- (void)keyboardWillHide:(NSNotification *)aNotification
{
NSLog(@"keyboardWillHide");
}

This behaviour is causing issues in our app, when there are cascading
alerts triggered from the previous alertview'd delegate - bringing up the
keyboard in unneeded situations.

Any help /advice is greatly appreciated!

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Swift - Basic query regarding managedObjectContext method invocation from app delegate

2014-10-14 Thread Devarshi Kulshreshtha
I know about NSBatchUpdateRequest and NSAsynchronousFetchRequest, is
there any other fun part in modern world which can help me in my
requirement, excited to know ;)

On Wed, Oct 15, 2014 at 1:13 AM, Jerry Krinock  wrote:
>
>> On 2014 Oct 14, at 05:42, Devarshi Kulshreshtha 
>>  wrote:
>>
>> I am trying to implement reset functionality in core data based sample app.
>>
>> I think that there are two ways to implement reset functionality:
>>
>> Approach 1: Delete sqlite file and then re-insert data
>
> As you’ve seen, this is tricky to do without relying on some 
> Apple-impleentation-dependent behaviors.
>
>> Approach 2: Retrieve all data in managedObjectContext, delete
>> retrieved data  and then re-insert data
>
> Performance may be unacceptable, and people will disrespect your code :)
>
> * * *
>
> How about a third approach: perform a managed object context reset(), 
> followed by a save().  Does that work?
>
> Finally, if you’re in the modern world of Yosemite or iOS8, maybe some of the 
> new direct database access methods will do what you want.
>
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/devarshi.bluechip%40gmail.com
>
> This email sent to devarshi.bluec...@gmail.com



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Swift - Basic query regarding managedObjectContext method invocation from app delegate

2014-10-14 Thread Devarshi Kulshreshtha
I am trying to implement reset functionality in core data based sample app.

I think that there are two ways to implement reset functionality:

Approach 1: Delete sqlite file and then re-insert data

Approach 2: Retrieve all data in managedObjectContext, delete
retrieved data  and then re-insert data

I tried 'Approach 1' first, here is the code snippet:

@IBAction func resetData(sender: AnyObject) {

let appDelegate = UIApplication.sharedApplication().delegate
as AppDelegate

// delete old db if it exists
var url =
appDelegate.applicationDocumentsDirectory.URLByAppendingPathComponent("MyApp.sqlite")

let defaultFileManager = NSFileManager.defaultManager()

if defaultFileManager.fileExistsAtPath(url.path!) {
defaultFileManager.removeItemAtURL(url, error: nil)
}

let managedObjectContext = appDelegate.managedObjectContext!

var menuCategory : MenuCategories =
NSEntityDescription.insertNewObjectForEntityForName("MenuCategories",
inManagedObjectContext: managedObjectContext) as MenuCategories


appDelegate.saveContext()
}

Then I added a break point in appDelegate's managedObjectContext lazy
initialization method, here is the related code snippet:

lazy var managedObjectContext: NSManagedObjectContext? = {

let coordinator = self.persistentStoreCoordinator
if coordinator == nil {
return nil
}
var managedObjectContext = NSManagedObjectContext()
managedObjectContext.persistentStoreCoordinator = coordinator
return managedObjectContext
}()

First time when I performed reset action, the program counter (PC)
stopped on the added break point, but next time when I performed reset
action then the PC did not stop on the break point and app crashed for
obvious reasons:

Error Domain=NSCocoaErrorDomain Code=4 "The operation couldn’t be
completed. (Cocoa error 4.)" UserInfo=0x78f54ff0
{NSUnderlyingError=0x78f69250 "The operation couldn’t be completed. No
such file or directory"

Now my question is -

Why second time managedObjectContext initialization method was not invoked?

I know that I need to go back and learn Swift basics - the hard way,
perhaps there is some obvious reasons which I am missing, please
suggest.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: XPCService not getting launched from app

2014-10-12 Thread Devarshi Kulshreshtha
I tried to refer 'AppSandboxLoginItemXPCDemo' sample from apple:

https://developer.apple.com/library/mac/samplecode/AppSandboxLoginItemXPCDemo/Introduction/Intro.html#//apple_ref/doc/uid/DTS40012292-Intro-DontLinkElementID_2"]AppSandboxLoginItemXPCDemo

When I tried to run it on XCode 6, it displayed error message - 'No
signing identity found'. Since I don't have registered mac developer
account, in build settings for - iDecide and iDecideHelper I changed
'Code Signing Identity' as 'Don't Code Sign'.

I got a warning for each of the targets:

'Code Sign warning: CODE_SIGN_ENTITLEMENTS specified without
specifying CODE_SIGN_IDENTITY. It is not possible to add entitlements
to a binary without signing it.'

This time when I compiled the build, it worked as expected.

Now I tried to follow the steps specified in its ReadMe.txt file,
specifically I performed these steps in my sample app:

Step 1: Updated - Main App Target -> Capabilities Tab

a. Turned on 'App Sandbox'
b. Turned on 'App Groups'
c. Added an app group - 'XYZ'

Step 2: Updated - Helper Target -> Capabilities Tab

a. Turned on 'App Sandbox'
b. Enabled 'Outgoing Connections (Client)'
c. Turned on 'App Groups'
d. Added an app group - 'XYZ'

Step 3: Updated - Helper Target -> General Tab -> Bundle Identifier,
added 'XYZ' prefix to it.

On running the app in console it displayed these messages:

10/12/14 6:27:42.159 PM xpcd[554]: (null): Code identity[pid:
11875::Devarshi-Kulshreshtha.XPCShootOut
(/Users/devarshi/Library/Developer/Xcode/DerivedData/XPCShootOut-aaedwraccpinnndivoaqkujcmhmj/Build/Products/Debug/XPCShootOut.app)]
is not in ACL for container:
~/Library/Containers/Devarshi-Kulshreshtha.XPCShootOut/Data --
allowing access.

10/12/14 6:27:43.712 PM appleeventsd[63]:  A
sandboxed application with pid 11875, "XPCShootOut" checked in with
appleeventsd, but its code signature could not be validated ( either
because it was corrupt, or could not be read by appleeventsd ) and so
it cannot receive AppleEvents targeted by name, bundle id, or
signature. Error=ERROR: #100013  {
"NSDescription"="SecCodeCopySigningInformation() returned 100013, -."
}  (handleMessage()/appleEventsD.cp #2072) client-reqs-q

Neither app performed its intended function nor it displayed the log
message added in 'listener:shouldAcceptNewConnection:' delegate.

I am clueless. Kindly suggest if I am missing any thing? Is it
possible to get XPC service sample app working without a registered
mac developer account?

On Fri, Oct 10, 2014 at 11:23 AM, Devarshi Kulshreshtha
 wrote:
> I am trying a simple sample app on XPCServices, in which I am
> following below steps:
>
> Step 1: Created a sample project and added target - XPCServices with
> name - HelperProcess to it. When the target is created XCode
> automatically generates below files:
>
>  1. HelperProcessProtocol.h
>  2. HelperProcess.h
>  3. HelperProcess.m
>  4. main.m
>
> Step 2: In main.m added a log statement within implementation of
> ServiceDelegate:
>
> - (BOOL)listener:(NSXPCListener *)listener
> shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
> // This method is where the NSXPCListener configures, accepts,
> and resumes a new incoming NSXPCConnection.
> NSLog(@"Log which is never displayed :(");
> // Configure the connection.
> // First, set the interface that the exported object implements.
> newConnection.exportedInterface = [NSXPCInterface
> interfaceWithProtocol:@protocol(HelperProcessProtocol)];
>
> // Next, set the object that the connection exports. All
> messages sent on the connection to this service will be sent to the
> exported object to handle. The connection retains the exported object.
> HelperProcess *exportedObject = [HelperProcess new];
> newConnection.exportedObject = exportedObject;
>
> // Resuming the connection allows the system to deliver more
> incoming messages.
> [newConnection resume];
>
> // Returning YES from this method tells the system that you
> have accepted this connection. If you want to reject the connection
> for some reason, call -invalidate on the connection and return NO.
> return YES;
> }
>
> Step 3: In AppDelegate added below code in applicationDidFinishLaunching:
>
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> // Insert code here to initialize your application
>
> _connectionToService = [[NSXPCConnection alloc]
> initWithServiceName:@"HelperProcess"];
> _connectionToService.remoteObjectInterface = [NSXPCInterface
> interfaceWithProtocol:@

XPCService not getting launched from app

2014-10-09 Thread Devarshi Kulshreshtha
I am trying a simple sample app on XPCServices, in which I am
following below steps:

Step 1: Created a sample project and added target - XPCServices with
name - HelperProcess to it. When the target is created XCode
automatically generates below files:

 1. HelperProcessProtocol.h
 2. HelperProcess.h
 3. HelperProcess.m
 4. main.m

Step 2: In main.m added a log statement within implementation of
ServiceDelegate:

- (BOOL)listener:(NSXPCListener *)listener
shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts,
and resumes a new incoming NSXPCConnection.
NSLog(@"Log which is never displayed :(");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(HelperProcessProtocol)];

// Next, set the object that the connection exports. All
messages sent on the connection to this service will be sent to the
exported object to handle. The connection retains the exported object.
HelperProcess *exportedObject = [HelperProcess new];
newConnection.exportedObject = exportedObject;

// Resuming the connection allows the system to deliver more
incoming messages.
[newConnection resume];

// Returning YES from this method tells the system that you
have accepted this connection. If you want to reject the connection
for some reason, call -invalidate on the connection and return NO.
return YES;
}

Step 3: In AppDelegate added below code in applicationDidFinishLaunching:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application

_connectionToService = [[NSXPCConnection alloc]
initWithServiceName:@"HelperProcess"];
_connectionToService.remoteObjectInterface = [NSXPCInterface
interfaceWithProtocol:@protocol(HelperProcessProtocol)];
[_connectionToService resume];
}

Problem is -

When I launch the app, neither the log added in
listener:shouldAcceptNewConnection: is displayed nor the helper
process appears in Activity Monitor :(

Here is the code: https://github.com/Daemon-Devarshi/XPCShootOut

Note: I am trying this on XCode 6.0

Is there any additional setup which I need to do to make it working?
Please suggest.

-- 
Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Obtaining class of key at runtime

2014-10-06 Thread Devarshi Kulshreshtha
Scenario 1: Do not initialize instance variables in initWithPlist method

>
> In this case if I try to log class of key in setValue:forKey method,
> it prints nil
>
>
> That doesn't make any sense — it's illegal to pass a nil key to
> setValue:ForKey:. Who is calling this method?

This method is automatically called, since I am invoking
setValuesForKeysWithDictionary: in init method.

> Is there any way to achieve the same result in 'Scenario 1', may be by
> using any API from objective c runtime?
>
>
> Again, who is supposed to be calling setValue:forKey: if your init method
> isn't calling it?
> And why do you want to know the class of the key if it's clearly declared as
> NSString already? It's always going to be a string.

Actually I am indirectly trying to identify class of property, through
key parameter, the NSLog statement added within - setValue: forKey: is
wrong, I was trying to do something like this:

- (void)setValue:(id)value forKey:(NSString *)key
{
NSLog(@"key class: ",[[self valueForKey:key] class]); // it is
printing nil, prints correct value if key is initialized in init
method
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Obtaining class of key at runtime

2014-10-06 Thread Devarshi Kulshreshtha
I have a class with below interface:

@interface MyData : NSObject
@property (readwrite, strong) NSString *urlToParse;
@property (readwrite, strong) MappingElement *titleElement;


- (instancetype)initWithPlist:(NSString *)plistPath;

Its implementation is like this:

- (instancetype)initWithPlist:(NSString *)plistPath
{
if (self = [super init]) {
NSDictionary *plistData = [[NSDictionary alloc]
initWithContentsOfFile:plistPath];
[self setValuesForKeysWithDictionary:plistData];
}

return self;
}

#pragma mark KVC related methods
- (void)setValue:(id)value forKey:(NSString *)key
{
NSLog(@"key class: ",[key class]); // it is printing nil, prints
correct value if key is initialized in init method
}

Now there are two scenarios:

Scenario 1: Do not initialize instance variables in initWithPlist method

In this case if I try to log class of key in setValue:forKey method,
it prints nil

Scenario 2: Initialize instance variables in initWithPlist method

In this case if I try to log class of key in setValue:forKey method,
it prints NSString and then MappingElement.

Is there any way to achieve the same result in 'Scenario 1', may be by
using any API from objective c runtime?

Kindly suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Showing keyboard on SKScene - Swift

2014-09-28 Thread Devarshi Kulshreshtha
I am trying to show keyboard over an SKScene, I followed below steps:

1. Created a subclass of UIView - KeyboardDummyView
2. Implemented protocol UIKeyInput in it
3. Added a subview to GameViewController
4. Changed class of subview added to KeyboardDummyView

For some reasons it is not working as expected, here is the sample code:

https://github.com/Daemon-Devarshi/KeyboardOverSKScene

Kindly suggest if I am doing anything wrong?

Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-06-11 Thread Devarshi Kulshreshtha
Because of all the problems I faced I finally decided to use a third
party library - Chilkat

Here is the link: http://www.chilkatsoft.com/crypt-objc.asp

On Mon, May 19, 2014 at 10:56 PM, Jens Alfke  wrote:
>
> On May 19, 2014, at 3:06 AM, Devarshi Kulshreshtha
>  wrote:
>
> 5. Used - wrapSymmetricKey:keyRef: method defined in SecKeyWrapper
> class (CryptoExercise example) for encryption, and passed key obtained
> from step 3 and data to encrypt obtained from step 4 to it
>
>
> I think you’re misusing wrapSymmetricKey. The NSData you pass into it is not
> the message itself; it’s a raw symmetric key. The idea is that you create a
> symmetric key at random (probably 32 bytes for an AES-256 key), wrap
> (encrypt) that key using the recipient’s public key, encrypt your actual
> message using the symmetric key, and then send both the wrapped key and the
> encrypted message to the recipient.
>
> Problem: getting error - too much data for RSA block
>
>
> Yup. RSA can only encrypt a block of the same size as its key, so if you’re
> using RSA-2048 the maximum block size is 256 bytes. The padding formats used
> with RSA don’t support messages longer than that. In practice, the only
> things RSA encrypts are symmetric keys, never messages.
>
> (If you’re not familiar with concepts like wrapping and padding, you should
> really read a good book on cryptography before proceeding. It’s actually
> rather dangerous to work on this kind of stuff without a solid understanding
> of the principles, because the crypto building blocks can easily be misused
> to create systems that are insecure and easily exploited.)
>
> —Jens



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NS_DESIGNATED_INITIALIZER expected : (colon)

2014-06-09 Thread Devarshi Kulshreshtha
I am trying to declare a designated initializer like this:

- (instancetype)initWithDelegate:(id )delegate
NS_DESIGNATED_INITIALIZER;

But it is showing me this compilation error:

Expected ':'

Interestingly when I try to write it like this (reference link:
https://developer.apple.com/library/prerelease/ios/releasenotes/ObjectiveC/ModernizationObjC/AdoptingModernObjective-C/AdoptingModernObjective-C.html)
-

- (instancetype)init NS_DESIGNATED_INITIALIZER;

It shows this error:

Expected ';' after method prototype.

Any ideas on how to properly use NS_DESIGNATED_INITIALIZER?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: How to generate .cer file in cocoa

2014-05-21 Thread Devarshi Kulshreshtha
I need to share generated public key to other ios device, what is the
best way to share that?

On Wed, May 21, 2014 at 1:34 PM, Graham Cox  wrote:
>
> On 21 May 2014, at 5:41 pm, Devarshi Kulshreshtha 
>  wrote:
>
>>  am working on below scenario:
>>
>> 1. User A generates public key and private key
>> 2. User A shares public key to user B
>> 3. User B encrypts some data using shared public key
>> 4. User B sends encrypted data to user A
>> 5. User A decrypts data using related private key
>>
>> (Note: this is a part of problem which I am trying to solve, related
>> mail chain has subject: 'Share and store RSA - public key in java
>> server and vice versa')
>>
>> I found this sample code provided by apple -
>> https://developer.apple.com/library/mac/samplecode/CryptoCompatibility/Introduction/Intro.html
>>
>> Here they have discussed that we can extract public key from .cer
>> file, which means that if we want to share public key we need to share
>> .cer file.
>>
>> Is there any method to generate .cer file in cocoa?
>
>
> Probably, but why bother? Just use SecKeyGeneratePair(), part of the security 
> functions (assuming this is something private to an app of yours and not 
> needed for compatibility with an existing security protocol). A search in the 
> docs on that function will turn up something to go on.
>
> P.S. I've not used it myself, and I'm not offering this from experience - I 
> just googled how to generate key pair in Cocoa. There may be better 
> alternatives.
>
> --Graham



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to generate .cer file in cocoa

2014-05-21 Thread Devarshi Kulshreshtha
I am working on below scenario:

1. User A generates public key and private key
2. User A shares public key to user B
3. User B encrypts some data using shared public key
4. User B sends encrypted data to user A
5. User A decrypts data using related private key

(Note: this is a part of problem which I am trying to solve, related
mail chain has subject: 'Share and store RSA - public key in java
server and vice versa')

I found this sample code provided by apple -
https://developer.apple.com/library/mac/samplecode/CryptoCompatibility/Introduction/Intro.html

Here they have discussed that we can extract public key from .cer
file, which means that if we want to share public key we need to share
.cer file.

Is there any method to generate .cer file in cocoa?

Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-05-19 Thread Devarshi Kulshreshtha
This is what I am trying to achieve from some days now:

Approach #1:

~ Android End ~
1. Generated public and private key at an android device (using an
openssl wrapper)
2. Got modulus and exponent from the generated public key

~ iOS End ~
3. Generated public key from modulus and exponent, at ios end, using
code specified in this link:
http://stackoverflow.com/a/10643962/217586
4. Converted some sample string to an object of NSData using
NSUTF8StringEncoding
5. Used - wrapSymmetricKey:keyRef: method defined in SecKeyWrapper
class (CryptoExercise example) for encryption, and passed key obtained
from step 3 and data to encrypt obtained from step 4 to it
6. Converted NSData (encrypted data) obtained in previous step to
base64encoded string, shared the same to android guy

~ Android End ~
7. Tried to decrypt the base64encoded string, using related private key

Problem: getting error - too much data for RSA block

Approach #2: (Got to know from this link that -
https://github.com/superwills/iOSRSAPublicKeyEncryption, we are not
supposed to load public keys in iOS from anything other than a
certificate, so tried a different approach)

~ Terminal End ~
1. Generated certificate using openssl commands specified in this url:
http://stackoverflow.com/a/17295321/217586

~ iOS End ~
2. Obtained public key as specified in above url
3. Used below code to encrypt the data:

SecKeyWrapper *secKeyWrapper = [SecKeyWrapper sharedWrapper];
SecKeyRef obtainedPublicKey = [secKeyWrapper
getPublicKeyRefFromDerCertificate:kCertificatePath];
NSData *dataToBeEncrypted = [kStringToBeEncrypted
dataUsingEncoding:NSUTF8StringEncoding];
NSData *encryptedText = [secKeyWrapper
wrapSymmetricKey:dataToBeEncrypted keyRef:obtainedPublicKey];

4. Converted NSData to base64encoded string

~ Terminal End ~
5. Used below command to convert it back to original string:
echo  | openssl rsautl
-decrypt -inkey rsaPrivate.pem

Problem: getting error - rsa routines:RSA_EAY_PRIVATE_DECRYPT:data
greater than mod
len:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/rsa/rsa_eay.c

Any suggestions?

On Fri, May 16, 2014 at 10:40 PM, ChanMaxthon  wrote:
> Keychain is okay, I just cannot bear the crypto libraries.
>
> Sent from my iPhone
>
>> On May 17, 2014, at 1:08 AM, Jens Alfke  wrote:
>>
>>
>>> On May 16, 2014, at 12:37 AM, ChanMaxthon  wrote:
>>>
>>> I got fed up by Apple already and found a little BSD-licensed CXX crypto 
>>> library called Botan. I will either wrap it in Objective-C or rewrite it 
>>> for my later projects.
>>
>> I’m cautious of ‘alternative’ crypto implementations; there’s a lot of 
>> complex math and logic involved that’s easy to get wrong. I want the 
>> implementation I use to be as battle-tested as possible.
>>
>> Also, the Keychain is a valuable place to store secrets that, being built 
>> into the OS, offers better security than anything you can do on your own or 
>> with 3rd party libraries. There’s not really any other good solution for 
>> storing keys, short of making the user type in a strong passphrase every 
>> time they launch the app. Too bad the Keychain APIs are the worst part of 
>> the Security framework :(
>>
>> —Jens
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/devarshi.bluechip%40gmail.com
>
> This email sent to devarshi.bluec...@gmail.com



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-05-14 Thread Devarshi Kulshreshtha
I agree with Jens, that's why we opted for creating public-private key
pair on device itself.


On Wed, May 14, 2014 at 8:02 PM, Jens Alfke  wrote:
>
> On May 14, 2014, at 7:15 AM, Roland King  wrote:
>
>> If you ask a similar question to the original poster on any of the Apple 
>> Developer Forums you'll be advised not to generate key pairs on a device but 
>> to do it on a server (the advice will probably come from Quinn)
>
> That’s a weird idea. If the server creates the key-pair, then the server 
> knows your private key, which I would consider a major security breach. If 
> you’re going to trust the server with your credentials, you might as well 
> skip the fiddly encryption stuff altogether and save yourself a lot of work. 
> Otherwise the public keys and certs are just mumbo-jumbo to give the 
> appearance of security.
>
> Put another way: one of the major purposes of public-key crypto is to put you 
> in charge of your own encryption. You generate a key-pair locally on your 
> device/computer, and the private key is known only to you and never leaves 
> that device (except maybe inside a passcode-protected PKCS12 file.) I think 
> of private keys as being like nuclear fuel rods — you keep them in a heavily 
> shielded container (the Keychain) and never let them be exposed to daylight. 
> If you do that, you have a very secure system.
>
> —Jens
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/devarshi.bluechip%40gmail.com
>
> This email sent to devarshi.bluec...@gmail.com



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Devarshi Kulshreshtha
@Jens thanks for informing about apple_cdsa list, I am definitely
going to trouble guys over there ;)

I am correcting the steps which I wrote before:

1. SecKeyWrapper *keyWrapper = [SecKeyWrapper sharedWrapper];
2. [keyWrapper generateKeyPair];
2. NSData *publicKeyData = [keyWrapper getPublicKeyBits];

Now I am going to try at other end in android code to decode this data
and will try to get the public key object.

if CryptoExample is out of date, then what is the other best other
option for me, from the previous discussion I am unable to extract
anything useful which will help me to resolve my problem :-(

On Tue, May 13, 2014 at 10:07 PM, Jens Alfke  wrote:
> On May 13, 2014, at 22:20, Devarshi Kulshreshtha
>  wrote:
>
> In CyrptoExercise sample provided by apple, we have a wrapper class:
> SecKeyWrapper.
>
>
> First, I think CryptoExercise is out of date. It’s not included in Xcode
> 5.1’s doc set. I found it on Apple’s website, but it looks like it was last
> updated for iOS 3, and it has a bunch of obsolete workarounds for running in
> the simulator (a long time ago the Keychain APIs were different in the
> device and simulator environments.)
>
> Shall I use below code to create and send an encoded string to server:
>
> 1. SecKeyWrapper *keyWrapper = [SecKeyWrapper sharedWrapper];
> 2. NSData *publicKeyData = [keyWrapper getPublicKeyBits];
>
>
> It’s sample code, not a black box, so you can look at what it does yourself.
> The two lines you gave aren’t going to do anything by themselves —
> getPublicKeyBits just reads an already-existing public key out of the
> Keychain and encodes it. You have to generate the key first.
>
> —Jens
>
> PS: This discussion really belongs on the apple_cdsa list, which is for
> crypto/security discussions. Unfortunately Apple’s engineers never help out
> on that list (unlike on xcode-users or macnetworkprog), but there are some
> other fairly knowledgeable people there.



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Devarshi Kulshreshtha
Thanks for your suggestions.

I have one specific question:

In CyrptoExercise sample provided by apple, we have a wrapper class:
SecKeyWrapper. In this class we have one method: - (NSData
*)getPublicKeyBits. Shall I use below code to create and send an
encoded string to server:

1. SecKeyWrapper *keyWrapper = [SecKeyWrapper sharedWrapper];
2. NSData *publicKeyData = [keyWrapper getPublicKeyBits];
3. NSString *stringToSend = [publicKeyData
base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];

And expect that at android device, it will be decoded in this order:

1. string will be decoded to ByteBuffer
2. From ByteBuffer corresponding key object will be generated

Or do we need to consider any other mechanism?

On Tue, May 13, 2014 at 5:43 PM, ChanMaxthon  wrote:
> Rounding stuff up, there are two broadly-implemented systems: PKCS and PGP.
>
> If you are using PKCS system, you need to operate a CA that your app trusts. 
> Your server issue issue new keys as certificates signed by your CA. Clients 
> provide keys using CSR which is confirmed when signed by the server (probably 
> using an intermediate CA). Programming wise most if not all system can 
> support PKCS or DER certificates.
>
> To use PGP system you need to use a PGP key server (a public one is okay) and 
> key exchange is done by exchanging key IDs and searching keys on the key 
> servers.
>
> Sent from my iPhone
>
>> On May 13, 2014, at 6:24 PM, Devarshi Kulshreshtha 
>>  wrote:
>>
>> My requirements are:
>>
>> Requirement 1: Share public key to java server.
>>
>> Steps:
>>
>> 1. Generate public-private keys in iOS app.
>> 2. Store the generated keys in keychain.
>> 3. Send generated public key to java server.
>> 4. Java server shall be able to store shared public key in database.
>>
>> Requirement 2: Store public key sent by java server.
>>
>> Steps:
>>
>> 1. Java server sends public key of other user.
>> 2. Process data sent by java server and generate public key from it.
>> 3. Store generated key in keychain, which can be later retrieved for
>> encrypting message to be transferred.
>>
>> I am able to achieve steps 1-2 in requirement 1 by using below method
>> defined in SecKeyWrapper class (CommonCrypto sample):
>>
>>
>>- (void)generateKeyPair:(NSUInteger)keySize
>>
>>
>> Question 1: Now problem is-  how shall I send that key to java server?
>>
>> We have getPublicKeyBits method in the same class, which returns an
>> NSData object, on some googling I found that it is in DER encoded
>> format.
>>
>> Question 2: If I send the same NSData object to server, which I guess
>> it will interpret as ByteBuffer object, will it be possible for other
>> devices, in my case it could be android, to interpret that data?
>>
>> Question 3: What is the best way to share public key in above scenarios?
>>
>> Please suggest.
>> ___
>>
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/xcvista%40me.com
>>
>> This email sent to xcvi...@me.com



-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Share and store RSA - public key in java server and vice versa

2014-05-13 Thread Devarshi Kulshreshtha
My requirements are:

Requirement 1: Share public key to java server.

Steps:

1. Generate public-private keys in iOS app.
2. Store the generated keys in keychain.
3. Send generated public key to java server.
4. Java server shall be able to store shared public key in database.

Requirement 2: Store public key sent by java server.

Steps:

1. Java server sends public key of other user.
2. Process data sent by java server and generate public key from it.
3. Store generated key in keychain, which can be later retrieved for
encrypting message to be transferred.

I am able to achieve steps 1-2 in requirement 1 by using below method
defined in SecKeyWrapper class (CommonCrypto sample):


- (void)generateKeyPair:(NSUInteger)keySize


Question 1: Now problem is-  how shall I send that key to java server?

We have getPublicKeyBits method in the same class, which returns an
NSData object, on some googling I found that it is in DER encoded
format.

Question 2: If I send the same NSData object to server, which I guess
it will interpret as ByteBuffer object, will it be possible for other
devices, in my case it could be android, to interpret that data?

Question 3: What is the best way to share public key in above scenarios?

Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Unable to use iOS framework which is internally using xib

2014-03-23 Thread Devarshi Kulshreshtha
I am trying to make a universal framework for iOS by following steps
specified in this URL:
http://blog.db-in.com/universal-framework-for-ios/

I have a view controller class within that framework which internally
loads a xib file.
Below is a part of code which shows how I am initializing that view
controller and showing related view:

/*** Part of implementation of SomeViewController class, which is
outside the framework ***/

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

self.viewControllerWithinFramework =
[[ViewControllerWithinFramework alloc] initWithTitle:@"My custom
view"];
}
- (IBAction)showSomeView:(id)sender {
[self.viewControllerWithinFramework showRelatedView];
}

/*** Part of implementation of ViewControllerWithinFramework
class, which is inside the framework ***/

- (id)initWithTitle:(NSString *)aTitle
{
   self = [super initWithNibName:@"ViewControllerWithinFramework"
bundle:nil]; // ViewControllerWithinFramework.xib is within the
framework

   if (self)
   {
   _viewControllerTitle = aTitle;
   }

   return self;
}

While creating the framework, I included all xibs, including
ViewControllerWithinFramework.xib within its 'Copy Bundle Resources'
build phase.

Now my problem is when I try to integrate that framework within other
project, it crashes with below stack trace:

Sample[3616:a0b] *** Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Could not load NIB in
bundle: 'NSBundle 
(loaded)' with name 'ViewControllerWithinFramework''
*** First throw call stack:
(
0   CoreFoundation  0x017365e4
__exceptionPreprocess + 180
1   libobjc.A.dylib 0x014b98b6 objc_exception_throw + 44
2   CoreFoundation  0x017363bb +[NSException
raise:format:] + 139
3   UIKit   0x004cc65c -[UINib
instantiateWithOwner:options:] + 951
4   UIKit   0x0033ec95
-[UIViewController _loadViewFromNibNamed:bundle:] + 280
5   UIKit   0x0033f43d
-[UIViewController loadView] + 302
6   UIKit   0x0033f73e
-[UIViewController loadViewIfRequired] + 78
7   UIKit   0x0033fc44
-[UIViewController view] + 35

Any ideas, how could I resolve this problem?

*Note: It works fine if there is no any xib within the framework.*
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Unable to use Managed Object Context proxy from Interface builder library

2013-11-24 Thread Devarshi Kulshreshtha
Resolved this problem, by using below code :-)

- (void)awakeFromNib

{

[self.listManagedObjectContext setPersistentStoreCoordinator:[
NSAppDelegate persistentStoreCoordinator]];

}


On Sun, Nov 24, 2013 at 2:53 PM, Devarshi Kulshreshtha <
devarshi.bluec...@gmail.com> wrote:

> I am making a simple mac os x app, in which I will be showing some records
> in a table view, after retrieving those from local db. I am using core data
> and NSArrayController proxy for the same and I am trying to achieve it
> through cocoa-bindings.
>
> Now I can easily make it working, by performing this binding in
> NSArrayController proxy:
>
> Proxy: NSArrayController
> Parameters: Managed Object Context
> Bind to: App Delegate
> Model Key Path: self.managedObjectContext
>
> but I am trying to use NSManagedObjectContext proxy from Interface builder
> library, for this binding:
>
> Proxy: NSArrayController
> Parameters: Managed Object Context
> Bind to: Managed Object Context
> Model Key Path: self
>
> I am surprised that there is no binding available for it, in bindings pan.
> At least there should be a binding to map persistent store coordinator to
> it.
>
> To assign MOC a persistent store coordinator, I am using below code:
>
> @property (strong) IBOutlet NSManagedObjectContext*listManagedObjectContext;
>
> [self.listManagedObjectContext setPersistentStoreCoordinator:[
> NSAppDelegate persistentStoreCoordinator]];
>
> Problem is - I am continuously getting this message in console:
>
> Cannot perform operation since managed object context has no persistent
> store coordinator
>
> With this stack backtrace:
>
> 0   CoreFoundation  0x7fff8b59fb06
> __exceptionPreprocess + 198
>
> 1   libobjc.A.dylib 0x7fff881103f0
> objc_exception_throw + 43
>
> 2   CoreFoundation  0x7fff8b59f8dc +[NSException
> raise:format:] + 204
>
> 3   AppKit  0x7fff907eb5e6
> -[_NSManagedProxy _persistentStoreCoordinator] + 81
>
> 4   AppKit  0x7fff907eb528
> -[_NSManagedProxy _entity] + 49
>
> 5   AppKit  0x7fff907eb43a
> -[_NSManagedProxy fetchRequestWithSortDescriptors:limit:] + 95
>
> 6   AppKit  0x7fff90cc04f0
> -[NSObjectController(NSManagedController)
> _executeFetch:didCommitSuccessfully:actionSender:] + 73
>
> My questions are -
>
> 1. What is the correct way of using NSManagedObjectContext proxy in
> interface builder library?
>
> 2. How can I resolve observed problem?
>
> Please suggest.
> --
> Thanks,
>
> Devarshi
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Unable to use Managed Object Context proxy from Interface builder library

2013-11-24 Thread Devarshi Kulshreshtha
I am making a simple mac os x app, in which I will be showing some records
in a table view, after retrieving those from local db. I am using core data
and NSArrayController proxy for the same and I am trying to achieve it
through cocoa-bindings.

Now I can easily make it working, by performing this binding in
NSArrayController proxy:

Proxy: NSArrayController
Parameters: Managed Object Context
Bind to: App Delegate
Model Key Path: self.managedObjectContext

but I am trying to use NSManagedObjectContext proxy from Interface builder
library, for this binding:

Proxy: NSArrayController
Parameters: Managed Object Context
Bind to: Managed Object Context
Model Key Path: self

I am surprised that there is no binding available for it, in bindings pan.
At least there should be a binding to map persistent store coordinator to
it.

To assign MOC a persistent store coordinator, I am using below code:

@property (strong) IBOutlet NSManagedObjectContext*listManagedObjectContext;

[self.listManagedObjectContext setPersistentStoreCoordinator:[NSAppDelegate
persistentStoreCoordinator]];

Problem is - I am continuously getting this message in console:

Cannot perform operation since managed object context has no persistent
store coordinator

With this stack backtrace:

0   CoreFoundation  0x7fff8b59fb06
__exceptionPreprocess + 198

1   libobjc.A.dylib 0x7fff881103f0
objc_exception_throw + 43

2   CoreFoundation  0x7fff8b59f8dc +[NSException
raise:format:] + 204

3   AppKit  0x7fff907eb5e6
-[_NSManagedProxy _persistentStoreCoordinator] + 81

4   AppKit  0x7fff907eb528
-[_NSManagedProxy _entity] + 49

5   AppKit  0x7fff907eb43a
-[_NSManagedProxy fetchRequestWithSortDescriptors:limit:] + 95

6   AppKit  0x7fff90cc04f0
-[NSObjectController(NSManagedController)
_executeFetch:didCommitSuccessfully:actionSender:] + 73

My questions are -

1. What is the correct way of using NSManagedObjectContext proxy in
interface builder library?

2. How can I resolve observed problem?

Please suggest.
-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Displaying untrusted certificate information in iOS app

2013-11-16 Thread Devarshi Kulshreshtha
one more quick question.. how can I extract information from this class:
SecCertificateRef

Its syntax seems to be very weird as compared to normal cocoa classes :-(

If you can give some example of extracting - organization name, email
address, and expiry date, it will be very helpful.


On Sat, Nov 16, 2013 at 8:46 PM, Jens Alfke  wrote:

>
> On Nov 16, 2013, at 6:41 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> Q1. How can I obtain above enlisted information? Is there any cocoa API to
> provide the same?
>
>
> SecCertificateRef
>
> Q2. Generally in a web browser it presents all details related to that
> certificate. Do we need to follow the same behavior in an iOS app?
>
>
> That’s up to you, I think.
>
> —Jens
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Displaying untrusted certificate information in iOS app

2013-11-16 Thread Devarshi Kulshreshtha
In my iOS app, I am trying to connect to a server, which has untrusted
certificate.

I am handling this situation by following the procedure as specified in
this url:

https://developer.apple.com/library/mac/documentation/cocoa/conceptual/urlloadingsystem/Articles/AuthenticationChallenges.html

This is working fine.

Now I have one requirement, in which I need to show details related to the
certificates such as:

1. Name
2. Location
3. Organization Unit
4. Email address
5. Not valid before date
6. Not valid after date
7. Signature algorithm

Now I have few questions:

Q1. How can I obtain above enlisted information? Is there any cocoa API to
provide the same?

Q2. Generally in a web browser it presents all details related to that
certificate. Do we need to follow the same behavior in an iOS app?

Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Identifying complete size of file when transfer is in progress

2013-11-15 Thread Devarshi Kulshreshtha
How can I poll the files? Is their any cocoa API to do so?


On Fri, Nov 15, 2013 at 6:21 PM, Jens Alfke  wrote:

>
> On Nov 15, 2013, at 4:10 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> > >> user will be copying these files directly through iTunes.
>
> You’ll just have to poll the files, then. When a new file appears, monitor
> its size every second or so. When the size hasn’t increased in the last,
> say, 10 seconds, assume it’s complete.
>
> —Jens




-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Identifying complete size of file when transfer is in progress

2013-11-15 Thread Devarshi Kulshreshtha
Hi Jens,

Regarding:

You haven’t stated where these files are coming from. Is this a network
download? In that case you can use NSURLConnection’s delegate methods to
find the size of the file and watch the download progress. If it’s some
other API, check whether it has progress monitoring.

>> user will be copying these files directly through iTunes.


On Fri, Nov 15, 2013 at 6:08 PM, Jens Alfke  wrote:

>
> On Nov 15, 2013, at 1:28 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> When I am trying to add a large file, such as a movie file, then as soon as
> transfer starts (copy or move operation) it invokes directoryDidChange:
> immediately. It did not wait unless the transfer is complete. So I always
> get size as 0.
>
>
> Yup. The code that’s writing the file creates a new file, which starts
> empty, then writes data into it as it arrives. If you’re watching for new
> files, you’ll see the file when it’s created.
>
> 1. Is there any way to know the complete size of file, which is in transfer
> state. eg. if message displayed is copying 30 MB of 100 MB, I want to get
> 100 MB?
>
>
> Not at that level. The file will just keep growing until it’s complete.
>
> 2. Is there any alternative of DirectoryWatcher, which notifies only when
> file is completely added?
>
>
> You haven’t stated where these files are coming from. Is this a network
> download? In that case you can use NSURLConnection’s delegate methods to
> find the size of the file and watch the download progress. If it’s some
> other API, check whether it has progress monitoring.
>
> —Jens
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Deleting 20000 files in applicationWillTerminate

2013-11-15 Thread Devarshi Kulshreshtha
In my iPhone app, I am downloading files from server and storing them
locally (user's document directory). The path of each file downloaded is
subsequently updated in database.

If user tries to delete a file, first the file is deleted from local path
using removeItemAtPath: (NSFileManager), then corresponding record is
deleted from database.

Now I have one of the requirements according to which user can turn on a
UISwitch to delete all data on app exit.

Now my question is - suppose user downloaded 2 files, say small images,
and user turned on the switch to delete all data on app exit. Is it good to
handle this task in applicationWillTerminate? What is the best way to
accomplish this scenario?

Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Identifying complete size of file when transfer is in progress

2013-11-15 Thread Devarshi Kulshreshtha
In my iphone app, I am displaying information of files added to documents
directory, in a table view, as soon as those are added. For this I am using
DirectoryWatcher class provided in one of the sample codes by apple.

Below is the block of code showing its use:

- (void)viewDidLoad
{
// start monitoring the document directory…
self.aDirectoryWatcher = [DirectoryWatcher watchFolderWithPath:[self
applicationDocumentsDirectory] delegate:self];

// scan for existing documents
[self directoryDidChange:self.aDirectoryWatcher];
}

- (void)directoryDidChange:(DirectoryWatcher *)folderWatcher
{
[self reconcileData];
}

One of the information displayed in table view cell is- file size, which I
am obtaining as below:

NSDictionary *fileAttributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:[fileURL path] error:nil];
NSNumber * size = [fileAttributes objectForKey:NSFileSize];

Problem is-

When I am trying to add a large file, such as a movie file, then as soon as
transfer starts (copy or move operation) it invokes directoryDidChange:
immediately. It did not wait unless the transfer is complete. So I always
get size as 0.
In case of small sized files, such as images, it works fine.

Now I have two question:

1. Is there any way to know the complete size of file, which is in transfer
state. eg. if message displayed is copying 30 MB of 100 MB, I want to get
100 MB?

2. Is there any alternative of DirectoryWatcher, which notifies only when
file is completely added?

Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

UITextView created programmatically, allowing selection but no edit, ios6+

2013-10-15 Thread Devarshi Kulshreshtha
I am trying to create a UITextView programmatically using below code:


- (void)setupTextView

{

if (!_logDetailView) {

CGSize viewSize = self.view.bounds.size;

CGRect frame =CGRectMake(0.0f,2.0f , viewSize.width,
viewSize.height);



_logDetailView =[[UITextView
alloc]initWithFrame:CGRectIntegral(frame)];

_logDetailView.backgroundColor=kEMCColor_Clear_Color;

_logDetailView.showsHorizontalScrollIndicator = NO;

  //  _logDetailView.editable = YES; // tried setting this but
didn't work

  //  _logDetailView.selectable = YES; // crashing on ios 6

_logDetailView.userInteractionEnabled = YES;

_logDetailView.autoresizingMask
=UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleBottomMargin;



 //   _logDetailView.allowsEditingTextAttributes = YES; // tried
setting this but didn't work



[self.view addSubview:_logDetailView];

}



_logDetailView.attributedText = self.attributedDataString;



}


I am trying to achieve following thing:


> UITextView should be selectable but un-editable.


My problems are:


1. I tried to set selectable property as YES, but it crashed on iOS6.

2. I tried to set it as editable, but neither I was able to select the
text, nor it showed any keyboard to edit it.

2. I tried to set allowsEditingTextAttributes as YES, but neither I was
able to select the text, nor it showed any keyboard to edit it.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

UIActivityViewController not displaying third party apps

2013-10-06 Thread Devarshi Kulshreshtha
I am trying to use UIActivityViewController as open-in option in my app.

I am using below code:

- (void)displayThroughOpenIn
{

NSString *localFilePathString = [self
generateLocalPathForFile:self.mCurrentFile];
NSURL *localFilePath = [NSURL fileURLWithPath:localFilePathString];

NSArray *activityItems = @[localFilePath];

//-- initialising the activity view controller
UIActivityViewController *avc = [[UIActivityViewController alloc]
 initWithActivityItems:activityItems
 applicationActivities:nil];

//-- define the activity view completion handler
avc.completionHandler = ^(NSString *activityType, BOOL completed)
{
if (completed) {
}
else
{
// cancel button clicked
// poup the view controller from navigation view stack
[self popToBackViewController];
}
};

//-- define activity to be excluded (if any)
avc.excludedActivityTypes = [NSArray
arrayWithObjects:UIActivityTypeAssignToContact, nil];

//-- show the activity view controller
[self presentViewController:avc
   animated:YES completion:nil];
}

Problem is - It is not displaying any of the third party apps, such as
adobe reader, chrome.

I think this is because I am passing applicationActivities as nil in –
initWithActivityItems:applicationActivities: .

If this is the case then do I need to subclass UIActivity for each of the
third party apps and it will not support those apps by default?

Please clarify.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

txt file renamed to mp3, MPMoviePlayerPlaybackDidFinishReasonUserInfoKey returning 0

2013-10-03 Thread Devarshi Kulshreshtha
I am trying to identify if a file can be played in MPMoviePlayer or not,
for this I have added below code in viewDidLoad:

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:_fileDisplayMoviePlayer];

and defined it like this:

- (void)moviePlayBackDidFinish:(NSNotification*)notif
{
NSNumber* reason = [[notif userInfo]
objectForKey:MPMoviePlayerPlaybackDidFinishReasonUserInfoKey];
switch ([reason intValue]) {
case MPMovieFinishReasonPlaybackEnded:
NSLog(@"Playback Ended");
break;
case MPMovieFinishReasonPlaybackError:
NSLog(@"Playback Error");
[self performSelector:@selector(CorruptVideoAlertView)
withObject:nil afterDelay:1.0];
break;
case MPMovieFinishReasonUserExited:
NSLog(@"User Exited");
break;
default:
break;
}

To verify it, I used below test case scenario:

I changed the extension of .rtf file to .mp3, and tried to play it
in player.

Though notification was invoked, it returned reason as -
MPMovieFinishReasonPlaybackEnded. It should have returned -
MPMovieFinishReasonPlaybackError.

Please suggest how can I test the above scenario, and get the expected
result.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: viewForZoomingInScrollView working but with extra blank space

2013-10-02 Thread Devarshi Kulshreshtha
I have uploaded the sample code over here: https://db.tt/wrNjTLkV


On Wed, Oct 2, 2013 at 9:26 PM, Devarshi Kulshreshtha <
devarshi.bluec...@gmail.com> wrote:

> I am trying to implement default photos app like functionality.
>
> I have added an image view to scroll view and implemented below method:
>
> - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
> {
> return self.fileDisplayImageView;
> }
>
> Problem is though it is zooming the image, it is adding space around its
> bounds when zoomed.
>
> Below is the original image:
>
> http://i.stack.imgur.com/gE1ra.png
>
> Here is the image after zoom, with extra blank space added at top:
>
> http://i.stack.imgur.com/yGnsf.png
>
> Can any one suggest, how can I resolve this problem?
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

viewForZoomingInScrollView working but with extra blank space

2013-10-02 Thread Devarshi Kulshreshtha
I am trying to implement default photos app like functionality.

I have added an image view to scroll view and implemented below method:

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return self.fileDisplayImageView;
}

Problem is though it is zooming the image, it is adding space around its
bounds when zoomed.

Below is the original image:

http://i.stack.imgur.com/gE1ra.png

Here is the image after zoom, with extra blank space added at top:

http://i.stack.imgur.com/yGnsf.png

Can any one suggest, how can I resolve this problem?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Disabling copy operation in QLPreviewController

2013-10-02 Thread Devarshi Kulshreshtha
Is there any way to disable copy of content when we are viewing a text
file, in QLPreviewController?

I tried to sub-class it and override- canBecomeFirstResponder and returned
NO, but it did not work :-(

Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Configuring bottom bar in QLPreviewController

2013-10-02 Thread Devarshi Kulshreshtha
I have integrated QLPreviewController and UIDocumentInteractionController
in my app, and it is working fine.

The only problem is- I want to configure the bottom toolbar, I want to
remove the default toolbar items, which appear as shown in this image :

http://i.stack.imgur.com/rm9fe.png

Is there any way to do so, please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

QLPreviewController - Implementation as in DocInteraction sample

2013-09-29 Thread Devarshi Kulshreshtha
I have a tab bar based app,on tap of each tab bar item, I am showing a
navigation controller. In root view controller, I am showing a list of
files. Once user taps a row, I am pushing a UIViewController. So content
area appears between the navigation bar and the tab bar.

I am trying to integrate the QLPreviewController in my app such that:

a. It behaves exactly the same way as in DocInteraction sample.
b. In the DocInteraction sample code, if it is a video file, it shows a
progress bar at top (below the navigation bar). I also want to display the
same.
c.  In the DocInteraction sample code, if it is a video file, it shows play
button over the video displayed. I also want to display the same.
d.  In the DocInteraction sample code, if it is a video file, it shows
pause button over the toolbar at bottom. I also want to display the same,
but on different location say on right side of navigation bar.

Problem is:  I tried to integrate QLPreviewController in my app using below
code, but in that case it is not working as expected. Also because of tab
bar at bottom, it is hiding the options to play/pause video.

In DocInteraction sample code, it is not clear that how did they customize
it. It seems too simple but it does not behave as same :-(

My questions are:

1. In my app, how can I move the default menu so that it appears above tab
bar.
2. How can I implement the points: b, c, d, which I specified above?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Identify extension of a file without extension

2013-09-28 Thread Devarshi Kulshreshtha
Thanks, will check for sure.. one more query.. will it be applicable in an
ios app? Mine is an iOS app.


On Sat, Sep 28, 2013 at 4:29 PM, Charles Srstka wrote:

> On Sep 28, 2013, at 4:17 PM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> > 1. Is there any other way to identify file extension for the files
> without
> > extensions, say from NSData object?
>
> Have a look at the files in /usr/share/file/magic/ to get some ideas of
> how to identify various types of files.
>
> Charles
>
> ___
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> https://lists.apple.com/mailman/options/cocoa-dev/devarshi.bluechip%40gmail.com
>
> This email sent to devarshi.bluec...@gmail.com




-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Identify extension of a file without extension

2013-09-28 Thread Devarshi Kulshreshtha
In my current application I am downloading few files from server, and
storing them locally.


Based on extension of file I am loading the file in appropriate view.


Example:


1. file extensions: mov, 3gp, m4a, etc., => display in media player.

2. file extensions: rtf, pptx, numbers, etc., =>display in UIWebView.

3. file extensions: gif, png, xbm, etc.,=>display in UIImageView.


Problem is: some of the downloaded files may not have any extension.


One approach which I found is- in connectionDidFinishLoading obtain
MIMEType from response and from that obtain file extension. I used below
code, for the same:


- (void)connectionDidFinishLoading:(NSURLConnection *)connection{

CFStringRef mimeType = (__bridge CFStringRef)[_respo MIMEType];

CFStringRef uti =
UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL);

CFStringRef extension = UTTypeCopyPreferredTagWithClass(uti,
kUTTagClassFilenameExtension);

NSString *fileName = [NSString stringWithFormat:@"%@.%@", [[_respo
suggestedFilename] stringByDeletingPathExtension], (__bridge NSString
*)extension];

[[NSFileManager defaultManager] createFileAtPath:[[self docsDir]
stringByAppendingPathComponent:[NSString stringWithFormat:@"Downloads/%@",
fileName]] contents:_downloadedData attributes:nil];

}


Now my questions are:


1. Is there any other way to identify file extension for the files without
extensions, say from NSData object?


2. In place of checking file extension, is there any other way to show the
file in appropriate view?


Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Cocoa + Automator : service to generate text files not working

2013-08-27 Thread Devarshi Kulshreshtha
I have one more question:

Can we add a menu item with submenu through Automator services?


On Tue, Aug 27, 2013 at 10:44 PM, Devarshi Kulshreshtha <
devarshi.bluec...@gmail.com> wrote:

> thnx tone.. you caught a silly mistake :-)
>
>
> On Tue, Aug 27, 2013 at 8:24 PM, Fritz Anderson 
> wrote:
>
>> On 27 Aug 2013, at 4:02 AM, Devarshi Kulshreshtha <
>> devarshi.bluec...@gmail.com> wrote:
>>
>> > My problem is the service created is not appearing when I am trying to
>> > right click a file in finder.
>> >
>> > Can anyone suggest if I missed anything?
>>
>> I'm not expert enough, and can't spare the time to become expert enough,
>> to criticize your code, but did you go to System Preferences > Keyboard (of
>> all places) > Keyboard Shortcuts (?!) > Services, verify that your service
>> is present, and that it is checked?
>>
>> — F
>>
>>
>
>
> --
> Thanks,
>
> Devarshi
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Cocoa + Automator : service to generate text files not working

2013-08-27 Thread Devarshi Kulshreshtha
thnx tone.. you caught a silly mistake :-)


On Tue, Aug 27, 2013 at 8:24 PM, Fritz Anderson wrote:

> On 27 Aug 2013, at 4:02 AM, Devarshi Kulshreshtha <
> devarshi.bluec...@gmail.com> wrote:
>
> > My problem is the service created is not appearing when I am trying to
> > right click a file in finder.
> >
> > Can anyone suggest if I missed anything?
>
> I'm not expert enough, and can't spare the time to become expert enough,
> to criticize your code, but did you go to System Preferences > Keyboard (of
> all places) > Keyboard Shortcuts (?!) > Services, verify that your service
> is present, and that it is checked?
>
> — F
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Cocoa + Automator : service to generate text files not working

2013-08-27 Thread Devarshi Kulshreshtha
I am trying to create an automator service using cocoa, which will simply
create a text file with the name of files selected, at the same path, for
which I wrote below code:

- (id)runWithInput:(id)input fromAction:(AMAction *)anAction
error:(NSDictionary **)errorInfo
{
// Add your code here, returning the data to be passed to the next action.
NSArray *fileURLs = (NSArray *)input;

size_t count = [fileURLs count];

dispatch_apply(count, dispatch_get_global_queue(0, 0), ^(size_t i) {
NSURL *fileURL = [fileURLs objectAtIndex:i];

NSData *data = [@"some crude text ;)"
dataUsingEncoding:NSUTF8StringEncoding];

//changing name of file
NSString *filePathWithoutExtension = [[fileURL path]
stringByDeletingPathExtension];
NSString *filePathWithNewExtension = [[NSString alloc]
initWithFormat:@"%@.%@",filePathWithoutExtension,@"txt"];

[data writeToFile:filePathWithNewExtension atomically:NO];

});

// no need to return anything
return nil;
}

I added below values in info.plist file:

AMAccepts: Types: Item 0: com.apple.cocoa.url
AMCategory: AMCategoryPhotos

I imported the action to the automator, and added it to the default service
template.

The options selected in input template are:

1. Service receives selected: URLs
2. in: Finder
3. Input is: only URLs

My problem is the service created is not appearing when I am trying to
right click a file in finder.

Can anyone suggest if I missed anything?
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Modifying the default -Prefix.pch file

2013-08-25 Thread Devarshi Kulshreshtha
I would like to know how I can modify the default .pch file included with
the xcode project templates.

Example: to add below #define in default pch file-


#define APP_DELEGATE ((AppDelegate*)[[UIApplication sharedApplication]
delegate])

I tried searching for a template .pch file within xcode's package with no
luck.


Please suggest.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Storyboard - container view - embed different views based on condition

2013-08-16 Thread Devarshi Kulshreshtha
In my storyboard app I have view hierarchy like this:


1. ParentViewController has a container view (dragged and dropped the
container view from library on to the view of parent view controller).


2. Container view can embed one of the three view controllers, based on
some condition.


While implementing second point I am facing problem.


If I try to do it in storyboard by control dragging from container view to
a view controller, I can select viewDidLoad - embed segue. This will
automatically embed the destination view controller, but then I will have
no option to embed other view controllers based on some condition, say on
tap of a different button.


Can anyone suggest me how can I implement the 2nd point?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Button on side menu not working

2013-07-28 Thread Devarshi Kulshreshtha
I am able to implement side menu functionality using below code:

-(IBAction)menu:(id)sender
{
if (!_menuView) {
_menuView=[[MenuWidget alloc]init];
_menuView.view.frame=CGRectMake(-160,0,160,440);
[self.view addSubview:_menuView.view];
[self.view sendSubviewToBack:_menuView.view];

_menuView.view.userInteractionEnabled = YES;
}



if(self.widgetFlag==0){
//  menuView.view.frame=CGRectMake(-160,20,160,548);
self.view.frame=CGRectMake(0, 20, 320, 548);
[UIView animateWithDuration:0.5
 animations:^{
 self.view.frame=CGRectMake(160, 20, 320,
548);
 //
menuView.view.frame=CGRectMake(0,20,160,548);
 }];

self.widgetFlag=1;
}
else{
self.view.frame=CGRectMake(160, 20, 320, 548);
// menuView.view.frame=CGRectMake(0,20,160,548);
[UIView animateWithDuration:0.5
 animations:^{
 self.view.frame=CGRectMake(0, 20, 320,
548);
 //
menuView.view.frame=CGRectMake(-160,20,160,548);
 }];
self.widgetFlag=0;
}
}

It is working properly, but only problem is:

> Button added on _menuView.view is not responding to associated action.

Please suggest if I am missing anything.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSSortDescriptor for A <-->> B <-->> C relationships

2013-07-10 Thread Devarshi Kulshreshtha
I am trying to initialize a NSFetchedResultsController.

In the data model I have 3 entities related to each other like this:

A <-->> B <-->> C

Entity 'A' has a property 'name' and entity 'C' has property 'someDate'.

I want to get all managedObjects belonging to entity 'A', sorted in
below order, when I fire a fetch request against it:

1. 'someDate' == today's date (AND) ascending order by name

2. ascending order by name

ie. first it should enlist the objects in 'A' for which 'someDate' in
'C' is today's date, this list should be further sorted by 'name',
then it should enlist remaining objects in 'A' (for which 'someDate'
!= today's date) sorted by 'name'

Please suggest how can I achieve it in a single fetch request.

-- 
Thanks,

Devarshi

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Post to a particular friend or friends group on Facebook

2013-07-04 Thread Devarshi Kulshreshtha
.. without using NSSharingServicePicker or UIActivityViewController


On Thu, Jul 4, 2013 at 10:31 PM, Devarshi Kulshreshtha <
devarshi.bluec...@gmail.com> wrote:

> We can post to all our friends on facebook using this key value pair:
>
> @"ACFacebookAudienceKey" : ACFacebookAudienceFriends
>
> Is there any way by which we can post to a particular friend group say -
> "Colleague" or "School Friends" or to post to a particular friend.
>
> Please suggest.
>
> --
> Thanks,
>
> Devarshi
>



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Post to a particular friend or friends group on Facebook

2013-07-04 Thread Devarshi Kulshreshtha
We can post to all our friends on facebook using this key value pair:

@"ACFacebookAudienceKey" : ACFacebookAudienceFriends

Is there any way by which we can post to a particular friend group say -
"Colleague" or "School Friends" or to post to a particular friend.

Please suggest.

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Managing relationships by fetching related objects within subclass of NSManagedObject

2013-02-09 Thread Devarshi Kulshreshtha
Hi Keary,

Thnx for your reply :-)

Regarding your answer to my 2nd query, I understand that once I map the
newEmployee to company, the inverse relationship from company to employee
will be by default, no need for me to map it back. So in that case should I
do a check, say- if( aCompanyObject.employee == nil) then only map the
relationship else not?

Also can you elaborate with a simple example about how to be watchful of
fault-firing?

Thanks,
Devarshi




On Sun, Feb 10, 2013 at 12:16 AM, Keary Suska wrote:

>
> On Feb 9, 2013, at 10:20 AM, Devarshi Kulshreshtha wrote:
>
> > Say I have an employee entity and a company entity in core data.
> >
> > So employee and company are related to each other like this:
> >
> > Employee <<---> Company
> >
> > Now I am trying to right a manageRelationships method in each class,
> > something like this:
> >
> >@interface Employee : NSManagedObject
> >- (void)manageRelationships;
> >@property (nonatomic, retain) Company *company; // for relationship
> >@property (nonatomic, retain) NSNumber *companyId; // acts as foreign
> > key
> >@end
> >
> >@implementation Employee
> >@dynamic company;
> >@dynamic companyId;
> >- (void)manageRelationships
> >{
> >   // prepare a predicate as @"companyId == %@",self.companyId
> >
> >   // execute a fetch request against Company entity
> >
> >   // map relationship using self.company = retrievedCompanyObject
> >}
> >
> > Now I have few questions:
> >
> > 1. Is it safe to fire fetch request and map a relationship, as
> implemented
> > above, within a subclass of NSManagedObject?
>
> Possibly, though you have to be watchful of fault-firing.
>
> > 2. Is their any better way to achieve it? (Idea behind above approach
> is- I
> > will be calling above method on each created managed object so that it
> > automatically manages and maps all associated relationships)
>
> Well, Core Data manages modeled relationships for you given a minimal
> relationship. For instance, when creating a new Employee, simply setting
> newEmployee.companyRelationship = companyObject will establish also the
> to-many side of the relationship as long as both are modeled. You can also
> do the reverse, inserting the Employee object into the Company to-many
> relationship collection (in a KVO-compliant way). Note that this is all
> fully and well documented in the Core Data docs.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Managing relationships by fetching related objects within subclass of NSManagedObject

2013-02-09 Thread Devarshi Kulshreshtha
Hi All,

I need some suggestions on an implementation.

Say I have an employee entity and a company entity in core data.

So employee and company are related to each other like this:

Employee <<---> Company

Now I am trying to right a manageRelationships method in each class,
something like this:

@interface Employee : NSManagedObject
- (void)manageRelationships;
@property (nonatomic, retain) Company *company; // for relationship
@property (nonatomic, retain) NSNumber *companyId; // acts as foreign
key
@end

@implementation Employee
@dynamic company;
@dynamic companyId;
- (void)manageRelationships
{
   // prepare a predicate as @"companyId == %@",self.companyId

   // execute a fetch request against Company entity

   // map relationship using self.company = retrievedCompanyObject
}

Now I have few questions:

1. Is it safe to fire fetch request and map a relationship, as implemented
above, within a subclass of NSManagedObject?

2. Is their any better way to achieve it? (Idea behind above approach is- I
will be calling above method on each created managed object so that it
automatically manages and maps all associated relationships)

Please suggest.

Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


identifying if an application is not responding

2012-07-08 Thread Devarshi Kulshreshtha
Hi All,

Is there any way to identify if an application is 'not responding' like
how it shows in 'Force Quit' window when an application is unresponsive.

I checked methods declared in NSApplicationDelegate, checked class
reference of NSRunningApplication but I did n't get any useful method or
property through which I can identify it.

Please suggest.

Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Unable to edit text field on view in status bar - menu item

2012-06-26 Thread Devarshi Kulshreshtha
Hi All,

In my application I have a status bar, showing a menu item. I have done
binding of a view to the menu item, in XIB, such that it shows view when
status item is clicked. I am showing a text field on the view.

Problem is - when application is active, I am able to edit content in text
field, but if it is inactive, say I clicked on safari and then clicked on
its status item, I am unable to edit content in text field.

Is there any solution to this problem?

Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Unable to pass NSString as argument in NSButton binding

2012-03-28 Thread Devarshi Kulshreshtha
Hi All,

I am trying to perform an action on a button using bindings, so I declared
and defined following method in my app-controller class:

- (void)selectFolderAtPath:(NSString *)path;

And I did following bindings on button in IB:

Argument:

Bind to: App Delegate
Model Key Path: sourcePath (this is a NSString property declared and
synthesized in App Delegate)
Selector Name: selectFolderAtPath:

Target:

Bind to: App Delegate
Model Key Path: self
Selector Name: selectFolderAtPath:

Problem is - if I de-select 'Argument' binding then only method is getting
invoked, otherwise it is not working.

Can any one suggest me - how can I pass a NSString as argument to
the method invoked, using cocoa-bindings?

Thanks,
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


How to show last name of user in text field whose first name is selected in popup button

2012-02-02 Thread Devarshi Kulshreshtha
Hi All,

I have an array of dictionary which contains two keys- firstName
and lastName and their values, eg.

firstName/ lastName

Steve/ Jobs
Andre/ Agassi
Christiano/ Ronaldo

User interface consists of a pop up button and a text field.

I am displaying first name of users in pop up button. I am able to show
first name of the user selected in pop button in the text field by using
following bindings:

NSArrayController

Content Array - AppDelegate - myArray

NSPopUpButton

content - Array Controller - arrangedObjects - firstName
selected value - AppDelegate - selectionValue

NSTextField

Value - AppDelegate - selectionValue

Here myArray is a property declared as NSArray and selectionValue is
a property declared as NSString declared in AppDelegate class.

Now I am getting clue less to implement this through bindings:
Text field should show last name of user whose first name is selected in
pop up button.

Can anyone suggest me some solution to implement it or is it
possible through bindings?

Thanks,
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSTextField subclass not working properly

2012-01-02 Thread Devarshi Kulshreshtha
Hi all,


I am using below code to subclass NSTextField-


- (void)drawRect:(NSRect)dirtyRect

{

// black outline

NSRect blackOutlineFrame = NSMakeRect(0.0, 0.0, [self
bounds].size.width, [self bounds].size.height-1.0);


NSGradient *gradient = nil;

if ([NSApp isActive]) {

gradient = [[NSGradient alloc] initWithStartingColor:[NSColor
colorWithCalibratedWhite:0.24 alpha:1.0] endingColor:[NSColor
colorWithCalibratedWhite:0.374 alpha:1.0]];

}

else {

gradient = [[NSGradient alloc] initWithStartingColor:[NSColor
colorWithCalibratedWhite:0.55 alpha:1.0] endingColor:[NSColor
colorWithCalibratedWhite:0.558 alpha:1.0]];

}

[gradient drawInBezierPath:[NSBezierPath
bezierPathWithRoundedRect:blackOutlineFrame xRadius:7.6 yRadius:7.6]
angle:90];




// top inner shadow

NSRect shadowFrame = NSMakeRect(1, 1, [self bounds].size.width-2.0,
10.0);

[[NSColor colorWithCalibratedWhite:0.88 alpha:1.0] set];

[[NSBezierPath bezierPathWithRoundedRect:shadowFrame xRadius:6.9
yRadius:6.9] fill];


// draw the keyboard focus ring if we're the first responder and the
application is active

if (([[self window] firstResponder] == [self currentEditor]) && [NSApp
isActive])

{

[NSGraphicsContext saveGraphicsState];

NSSetFocusRingStyle(NSFocusRingOnly);

[[NSBezierPath bezierPathWithRoundedRect:blackOutlineFrame
xRadius:8.6 yRadius:8.6] fill];

[NSGraphicsContext restoreGraphicsState];

}


// main white area


NSRect whiteFrame = NSMakeRect(1, 2, [self bounds].size.width-3.0,
[self bounds].size.height-7.0);

[[NSColor whiteColor] set];

[[NSBezierPath bezierPathWithRoundedRect:whiteFrame xRadius:8.6
yRadius:8.6] fill];


NSFont *stringFont = [NSFont fontWithName:@"Lucida Grande" size:18.0];


if ([[self stringValue] length] == 0) {

NSColor *txtColor = [NSColor grayColor];

NSDictionary *placeHolderDict = [NSDictionary


dictionaryWithObjectsAndKeys:txtColor,
NSForegroundColorAttributeName,stringFont,NSFontAttributeName,

 nil];


placeHolderString = [[NSAttributedString alloc]

 initWithString:[[self cell] placeholderString]
attributes:placeHolderDict];

[placeHolderString drawAtPoint:NSMakePoint(10.0,0.0)];

}

else {

NSColor *txtColor = [NSColor blackColor];

NSDictionary *txtDict = [NSDictionary

 dictionaryWithObjectsAndKeys:txtColor,
NSForegroundColorAttributeName,stringFont,NSFontAttributeName,

 nil];


placeHolderString = [[NSAttributedString alloc]

 initWithString:[self stringValue]
attributes:txtDict];

[placeHolderString drawAtPoint:NSMakePoint(6.0,4.0)];

}


}


But I am facing two problems:


First Problem: When a text field is selected, it is showing overlapping
white edges over round corners as shown in below image:


http://i.stack.imgur.com/8NJHW.png


Second Problem: When cursor is in textField1 and I am pressing tab key, it
is not moving to textField2 though in IB I have binded next key view of
textField1 as textField2.


Can any one suggest me some solution for above problems?


Thanks
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Filling gradient in NSTableHeaderView not working properly

2011-12-13 Thread Devarshi Kulshreshtha
Hi all,

I am trying to fill gradient in header of tableview. So far I am able to
achieve it by subclassing NSTableHeaderView and using this code in
it-

- (void)drawRect:(NSRect)dirtyRect {
// Drawing code here.

NSGradient *gradientToFill = [[NSGradient alloc]
initWithStartingColor:[NSColor colorWithCalibratedRed:0.8828125 green:
0.8984375 blue:0.91015625 alpha:1.0]
 endingColor:[NSColor colorWithCalibratedRed:
0.5546875 green:0.59765625 blue:0.66015625 alpha:1.0] ];
[gradientToFill drawInRect:dirtyRect angle:90];
}

So earlier it was appearing like this-

http://db.tt/PVE9rnXu


Now it is appearing like this-

http://db.tt/D1zrJJJa


As shown in above screen-shot, when I used this code I faced few problems:

1. Column header titles are not getting displayed.
2. Header column separators are not appearing.

Can anyone suggest me how to resolve these problems or some better way to
implement it?

Thanks !
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Simple PDF generation code not working as intended

2011-10-12 Thread Devarshi Kulshreshtha
Hi all,

I am trying a simple application to generate pdf from contents in a
text view.

I am using below code:

NSPrintInfo *pdfDisplayInfo = [[NSPrintInfo alloc]
initWithDictionary:[NSDictionary
dictionaryWithObjectsAndKeys:@"YES",NSPrintHeaderAndFooter,nil]];
[pdfDisplayInfo setVerticalPagination:NSAutoPagination];
[pdfDisplayInfo setHorizontalPagination:NSAutoPagination];
[pdfDisplayInfo setVerticallyCentered:NO];
NSFileManager *filemanager = [NSFileManager defaultManager];
NSMutableData *dataObtained = [[NSMutableData alloc] init];
NSPrintOperation *printOperation = [NSPrintOperation

PDFOperationWithView:contentView

insideRect:[contentView frame]

toData:dataObtained printInfo:pdfDisplayInfo];

[printOperation runOperation];
[filemanager createFileAtPath:[@"~/Documents/SamplePrint.pdf"
stringByExpandingTildeInPath] contents:dataObtained attributes:nil];

Problem is:

Though I have used setVerticalPagination as NSAutoPagination, content
in pdf generated is not distributed among multiple pages.

Can anyone suggest me - if I am doing anything wrong or missing
something?

Here is the link for, code :
http://db.tt/L9rM8NU7


Thanks,
Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSComboBox in NSTableView behaving strangely

2011-07-06 Thread Devarshi Kulshreshtha
same problem exists in NSPopUpButtonCell, it is changing the value in list
which appears on clicking it, as shown -

Original list: http://dl.dropbox.com/u/259/unique%20data.png

Changed list: http://dl.dropbox.com/u/259/redundant%20data.png

Bindings used in case of NSPopUpButtonCell are:

TableColumn with NSPopUpButtonCell -

Value Selection : Selected Value bind to -> Transactions, Controller
Key -> arrangedObjects,
Model Key Path -> relatedEntity.name

NSPopUpButtonCell

Value Selection : Content Values Bind to: Entities, Controller Key ->
arrangedObjects,
Model Key Path -> name

Note: code can be found here -
http://dl.dropbox.com/u/259/TableWithComboBoxExperi.zip

On Wed, Jul 6, 2011 at 11:44 AM, Quincey Morris  wrote:

> On Jul 5, 2011, at 04:11, Devarshi Kulshreshtha wrote:
>
> > When I am selecting a value in dropdown list of combobox cell, it is
> > changing the value of previously selected value to newly selected value,
> as
> > shown in below figure(s) -
>
> A combo box is a kind of text field, not a kind of menu, so yes it's going
> to edit the property that it's bound to.
>
> Use a NSPopUpButton instead.
>
>
>


-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSComboBox in NSTableView behaving strangely

2011-07-05 Thread Devarshi Kulshreshtha
Hi All,

I am trying a sample application, which enlists some entities to purchase
and their respective cost.

In data model I created two entities:

1. Daily Transaction (Attribute: cost, Relationship: relatedEntity)
2. Entity (Attribute: name, Relationship: dailyTransactions)

Controls used in XIBs and their bindings:

I. ArrayControllers -
a. DailyTransactions, corresponding to Daily Transaction entity.
b. Entities, corresponding to Entity entity


II. A table -
Col 1: EntityName column containing NSComboBoxCell (value : bind to ->
dailyTransactions, controller key -> arrangedObjects, model key path ->
relatedEntity.name)
Col 2: EntityCost column containing NSTextFieldCell with NSNumberFormatter
(value : bind to -> dailyTransactions, controller key -> arrangedObjects,
model key path -> cost)

» NSComboBoxCell in EntityName (content values : bind to -> Entities,
controller key -> arrangedObjects, model key path -> name)

Problem is -
When I am selecting a value in dropdown list of combobox cell, it is
changing the value of previously selected value to newly selected value, as
shown in below figure(s) -

Original list: http://dl.dropbox.com/u/259/unique%20data.png

Changed list: http://dl.dropbox.com/u/259/redundant%20data.png

Can anyone suggest me how to resolve it?

Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Core data - binding related problem in NSNumberFormatter and NSDatePicker

2010-12-16 Thread Devarshi Kulshreshtha
Hi Pat,

Regarding:

For #1, you have an non-ascii character at the front of the number formatter
> (in IB).


It is now working correctly when I am entering the price with $ symbol
prefixed, eg. $123,00 :)

I think that this is not user intuitive, user may not always know that he/
she has to prefix dollar symbol. I think it would have been good if:

1. I can somehow change the alert message which now says - "Formatting
Error" to "You should prefix dollar symbol".

2. Numberformatter can automatically prefix the '$' symbol to the entered
decimal number.

Do you know any way to implement these?

 For #2, you are only actually setting the value of the selected car.
>  However the value of the date (if you don't purposefully set it) is nil,
> and the Date Picker is not displaying a value for nil, so it is leaving the
> value in there.  Try adding two cars, and setting a value for each car.
>  Then it will change for each selection.  I discovered this by adding a text
> field, setting a date formatter on the text field, and binding the text
> field to the same binding as the date picker.


Your interpretation is correct, when I set the default value of
datePurchased attribute to some value say- 2010-12-10 in
MyDocument.xcdatamodel, it started working as intended.

So I am now thinking that can we set the default value to today's date in
xcdatamodel?

Also when I tried adding two or more cars and change their data value, I got
the same problem. I used date-picker according to my requirements.

-- 
Thanks,

Devarshi



-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Core data - binding related problem in NSNumberFormatter and NSDatePicker

2010-12-14 Thread Devarshi Kulshreshtha
Hi all,

I am trying a core-data sample application, from Cocoa Programming - Aaron
Hillegass.

In it there is an entity Car, with following properties:

1. condition - Int 16
2. datePurchased - Date
3. makeModel - String
4. onSpecial - Boolean
5. photo - Binary
6. price - Decimal

There are certain view objects such as-

1. TableView
2. DatePicker
3. Image Well, etc.

Some of the bindings performed are-

1. TableView -> TableColumn with NSNumberFormatter (set as currency) ->
 value: arrangedObjects.price
2. DatePicker -> value: selection.datePurchased

Problems are:

1. In TableColumn with NSNumberFormatter it is not accepting any decimal
numbers which I am entering for currency, such as - 123,00 or 123.45 or +235
or 567. It is always displaying this alert message: Formatting error.

2. Whenever I am selecting a row in table and changing its corresponding
value in date picker, it is simultaneously changing the values for other
records, ie. if for first row in table I have set it
to 12/25/2004, it is keeping it 12/25/2004 for other rows.

Can anyone help me to resolve my problems? The source code can be found
here: 
URL="http://db.tt/o9870RZ
"

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Application crashing due to unicode characters in string

2010-12-01 Thread Devarshi Kulshreshtha
Hi all,

I am making an application in which I have to store data from remote db into
local sqlite3 db.

Problem is - when any string to be inserted contains unicode character such
as: \U00a0 or \U2022 or \U2019, it crashes.

The part of code which crashes is this-

NSString *insertQuery = @"insert into XYZ(field1,field2) values
(@"1",[recordDict objectForKey:@"field2"]);

// recordDict contains value: @"\U00a0 \U00a0 \U00a0 \U00a0The
Cadfsdfsdfptain\U2019s" for key: @"field2"

sqlite3_stmt *insertStmnt;
const char *sql = [insertQuery cStringUsingEncoding:1];
printf("insertQuery - %s",sql); // it is showing insertQuery - (null) and
crashing at next line
if(sqlite3_prepare_v2(database, sql, -1, &insertStmnt, NULL) != SQLITE_OK){
NSLog(@"Error while creating insert statement.
'%s'",sqlite3_errmsg(database));
}

Can anyone suggest me how to resolve this problem?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Unable to play a .mp3 file directly using QTMovie

2010-10-05 Thread Devarshi Kulshreshtha
Hi all,

I am trying to play a .mp3 file on click of a button using this code:

 NSString 

*audioFilePath=[[audioInputTextField stringValue]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];NSURL

*audioUrl = [[NSURL

alloc] initWithString:audioFilePath];
QTMovie* soundToPlay = [[QTMovie alloc] initWithURL:audioUrl
error:nil];[soundToPlay play];


Here user is expected to enter a valid url for an audio file in text
field and then click button next to it to play, but it is not working
for me ie. no audio gets played :(

Can anyone suggest me, if I am doing anything wrong?

The sample code can be downloaded from here- http://db.tt/cDjFCZO

One of the example links which I tried was -
http://javamax.free.fr/sonorisation%20et%20radio/Linken%20Park%20-%20In%20The%20End.mp3
-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Highlighting only image over button when it is clicked

2010-09-01 Thread Devarshi Kulshreshtha
Hi all,

Right now when I set an image over a button and make it border-less and try
to click it, it always shows a rectangular portion highlighted along with
the image, which is the actual dimension of button clicked.

My requirement is: I want to highlight only the image over it, not the whole
rectangular portion.

Can anyone suggest me some logic to implement it?

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Storing help pages on Remote Server

2010-07-29 Thread Devarshi Kulshreshtha
Hi all,

I have made a sample application in which I am able to implement help book
via help viewer .

Right now it is storing and displaying content from application bundle, but
I want to implement Internet Primary help book content, in which it checks
the server to determine whether a newer version of each page is available
before displaying the page. If the server isn’t available, or if the page
has not been updated, then the local version is used.

I checked this url to implement it:
http://developer.apple.com/mac/library/documentation/Carbon/Conceptual/ProvidingUserAssitAppleHelp/authoring_help/authoring_help_book.html#//apple_ref/doc/uid/TP3903-CH206-CHDGIECE

In it they have specified:

To specify a remote server for your help content, do the following:

1. Click “Show Details.”
2. Click the checkbox labeled “Use remote URL for missing files and
updates.”
3. In the text field under this checkbox, enter the server address where
your remote help content is available.

Problem is: I cannot get - where to click "Show Details", where to click the
checkbox labeled is it done within XCode, within help viewer?

Can anyone suggest me exactly how to do it or some useful link to implement
it?

Thanks,

-- 
Thanks,

Devarshi
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com