objc.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2016 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package objcpkg
  5. import (
  6. "ObjC/Foundation/NSDate"
  7. "ObjC/Foundation/NSString"
  8. "ObjC/QuartzCore/CAMediaTimingFunction"
  9. )
  10. func Func() {
  11. NSDate.Date()
  12. CAMediaTimingFunction.FunctionWithControlPoints(0, 0, 0, 0)
  13. }
  14. func Method() string {
  15. d := NSDate.Date()
  16. return d.Description()
  17. }
  18. func New() {
  19. NSDate.New()
  20. CAMediaTimingFunction.NewWithControlPoints(0, 0, 0, 0)
  21. }
  22. func Error() {
  23. str, err := NSString.StringWithContentsOfFileEncodingError("<non-existent>", 0)
  24. if err == nil {
  25. panic("no error from stringWithContentsOfFile")
  26. }
  27. // Assert err is an error
  28. err = err.(error)
  29. if str != "" {
  30. panic("non-empty string from stringWithContentsOfFile")
  31. }
  32. str, err = NSString.NewWithContentsOfFileEncodingError("<non-existent>", 0)
  33. if err == nil {
  34. panic("no error from stringWithContentsOfFile")
  35. }
  36. // Assert err is an error
  37. err = err.(error)
  38. if str != "" {
  39. panic("non-empty string from initWithContentsOfFile")
  40. }
  41. }