7.5 C
New York
Friday, March 21, 2025
Home Blog Page 3773

Side Ratios in SwiftUI · objc.io


One of many modifiers that all the time puzzled me a bit was .aspectRatio. How does it actually work? As soon as I figured it out, it turned out to be easier than I believed.

One place the place we are able to discover out loads about how SwiftUI works is SwiftUI’s .swiftinterface file. That is situated inside Xcode. Inside your Terminal, go to /Functions/Xcode.app, and carry out the next command:

								discover . -path "*/SwiftUI.framework*swiftinterface"

							

There are just a few variants of the .aspectRatio API, however all of them boil right down to a single implementation:

								func aspectRatio(_ aspectRatio: CGFloat?, contentMode: ContentMode) -> some View {
    
}

							

The variant with CGSize simply calls this technique with dimension.width/dimension.peak, and .scaledToFit and .scaledToFill name this technique with the respective content material modes and an aspectRatio of nil.

After we name aspectRatio with a set side ratio, e.g. .aspectRatio(16/9, contentMode: .match), the side ratio implementation takes the proposed dimension, and proposes a brand new dimension to its little one. When the content material mode is .match, it suits a rectangle with the specified side ratio contained in the proposed dimension. For instance, if you suggest 100×100, it’s going to suggest 100×56.2 to its little one. While you select .fill as a substitute, it’s going to suggest 177.8×100 to its little one as a substitute.

I discovered this conduct by printing the proposed sizes. Extra on that under.

Maybe the most typical use of aspectRatio is mixed with a resizable picture, like so:

								Picture("take a look at")
    .resizable()
    .aspectRatio(contentMode: .match)

							

It will draw the picture to suit inside the proposed dimension. Observe that we don’t specify the precise side ratio: it’s derived from the underlying picture.

After we do not specify a set side ratio however use nil for the parameter, the side ratio modifier appears to be like on the splendid dimension of the underlying view. This implies it merely proposes nil×nil to the underlying view, and makes use of the results of that to find out the side ratio. For instance, when the picture experiences its splendid dimension as 100×50, the computed side ratio is 100/50.

The method then continues like earlier than: when the view was proposed 320×480, the picture shall be sized to 320×160 when the content material mode is about to .match, and 960×480 when the content material mode is about to .fill.

Determining proposed sizes

Proposed sizes will not be a part of the general public API of SwiftUI. Despite the fact that you completely want to grasp how this works with the intention to write efficient layouts, this is not actually documented. The one official place the place this conduct is described is within the wonderful 2019 WWDC speak Constructing Customized Views with SwiftUI.

Nonetheless, there’s a hack to do that. Contained in the interface file talked about above, I looked for “ProposedSize” and located a protocol named _ArchivableView which permits us to override sizeThatFits:

								struct MySample: _ArchivableView {
    var physique: some View {
        Rectangle()
    }
    
    func sizeThatFits(in proposedSize: _ProposedSize) -> CGSize {
        print(proposedSize.fairly)
        return proposedSize.orDefault
    }
}

							

We are able to now merely assemble a MySample with a side ratio and print the end result. As an alternative of a .body, you too can use .fixedSize() to suggest nil for the width and/or peak. Likewise, strive leaving out the primary parameter and see how .aspectRatio proposes nil to determine the perfect dimension of its little one view.

								MySample()
    .aspectRatio(100/50, contentMode: .fill)
    .body(width: 320, peak: 480)

							

Sadly the width and peak properties on _ProposedSize aren’t seen within the swift interface, so I had to make use of introspection to print these (and in addition add just a few helper strategies like .fairly and .orDefault). The total code is in a gist.

If you wish to be taught extra about how SwiftUI works, learn our ebook Considering in SwiftUI. When your organization is already constructing issues in SwiftUI — or is about to get began — contemplate reserving a SwiftUI Workshop to your staff.

Google Pledges To Strengthen Privateness With Gemini AI

0


Amidst privateness issues about Google Gemini AI assistant in Android units, the tech big has introduced clarifying the insurance policies. Google plans to share an in depth white paper elaborating on the way it plans to guard Android customers’ knowledge with Gemini AI.

Google Will Quickly Share Particulars About Gemini AI Privateness Practices

Google’s Gemini AI, previously known as ‘Bard,’ just lately gained traction after Android customers may entry the brand new AI assistant through their cell phones.

Gemini AI affords customers numerous AI-powered providers, similar to writing, studying, brainstorming concepts, and extra. Whereas the service appears helpful, customers have been skeptical about how their interplay with Gemini AI and the following knowledge sharing would affect their privateness.

AI interactions could generally contain delicate particulars, affecting person privateness if the service supplier shops the info. This will get much more intense in the case of Google – a agency notorious for harvesting customers’ knowledge.

Nonetheless, Google has now determined to clear the air by sharing an in depth write-up on how Gemini AI impacts customers’ privateness.

As defined in its latest submit, Google is ‘reimagining’ Android customers’ interplay with Gemini whereas respecting their privateness. Beneath is a fast evaluate of what Google defined.

  • Gemini securely handles customers’ non-public knowledge, similar to resume particulars or private stuff, with out involving any third get together.
  • Any delicate Android knowledge, similar to audio notes or photographs, stays saved with the person’s system.
  • Information processed within the cloud or on a tool stays confined inside Google’s safe end-to-end structure.

Furthermore, Google has listed different characteristic upgrades with Gemini AI to boost person expertise throughout common actions, similar to emails, knowledge sharing, and extra.

In response to a latest submit from Bleeping Pc, Google has even determined to share insights concerning the Gemini AI privateness practices through an in depth white paper.

Tell us your ideas within the feedback.

Nvidia’s new G-Sync displays now not want a devoted {hardware} module

0


Nvidia is bringing its full set of G-Sync options to displays that gained’t want a proprietary G-Sync module. Nvidia is partnering with MediaTek to combine all of its present and future G-Sync options into MediaTek scalers, eliminating the necessity for a devoted G-Sync module.

“We’re working with MediaTek to deliver G-Sync to their market main monitor scalers,” says Nvidia. “We are going to deliver all of the G-Sync applied sciences, together with our most up-to-date – Pulsar – to many extra players and we’ll proceed to create extra G-Sync applied sciences with the MediaTek scaler options​.”

Your subsequent G-Sync monitor gained’t want a devoted module.
Picture: Nvidia

G-Sync initially required a devoted module in 2013 to permit it to synchronize show refresh charges to a GPU, remove display tearing, and scale back show stutter and enter lag. In 2019, Nvidia launched G-Sync Suitable, a method to help variable refresh charge displays with FreeSync expertise as an alternative of requiring a G-Sync module.

Whereas many displays now ship with G-Sync Suitable help, most don’t embody all of Nvidia’s G-Sync options like low latency HDR, its Reflex Analyzer for measuring system latency, or ultra-low movement blur help. Nvidia’s work with MediaTek will open up this full suite of G-Sync tech to much more displays sooner or later.

The primary three displays to incorporate full G-Sync help utilizing MediaTek scalers are AOC’s Agon Professional AG276QSG2, Acer’s Predator XB273U F5, and Asus’ ROG Swift 360Hz PG27AQNR. All three of those displays have 360Hz refresh charges, 1440p decision, and HDR help. Additionally they embody G-Sync Pulsar help, Nvidia’s newest expertise to cut back movement blur and ghosting.

The primary three displays with full G-Sync help and no module.
Picture: Nvidia

Nvidia’s affirmation of a MediaTek partnership comes after months of rumors that the pair are additionally engaged on an Arm-based chip for AI PCs. This work could even prolong to a devoted chip for handheld gaming PCs. Nvidia presently provides its Tegra X1 GPU for the prevailing Nintendo Swap, and it’s additionally rumored to be delivery a extra highly effective customized chip for the upcoming Swap 2.

Nvidia hasn’t commented on the MediaTek AI PC rumors, however earlier reviews have steered Nvidia plans to launch Arm PC chips as quickly as 2025. Dell CEO Michael Dell additionally dropped a reasonably large trace that Nvidia may very well be about to enter the AI PC market subsequent yr throughout a Bloomberg interview in Might.

CISA warns of Jenkins RCE bug exploited in ransomware assaults


CISA warns of Jenkins RCE bug exploited in ransomware assaults

​CISA has added a crucial Jenkins vulnerability that may be exploited to achieve distant code execution to its catalog of safety bugs, warning that it is actively exploited in assaults.

Jenkins is a extensively used open-source automation server that helps builders automate the method of constructing, testing, and deploying software program by steady integration (CI) and steady supply (CD).

Tracked as CVE-2024-23897, this flaw is brought on by a weak spot within the args4j command parser that unauthenticated attackers can exploit to learn arbitrary recordsdata on the Jenkins controller file system by the built-in command line interface (CLI).

“This command parser has a characteristic that replaces an @ character adopted by a file path in an argument with the file’s contents (expandAtFiles),” the Jenkins staff defined. “This characteristic is enabled by default and Jenkins 2.441 and earlier, LTS 2.426.2 and earlier doesn’t disable it.”

A number of proof-of-concept (PoC) exploits had been revealed on-line days after Jenkins devs launched safety updates on January 24, with some honeypots reportedly catching exploitation makes an attempt simply sooner or later later.

Risk monitoring service Shadowserver presently tracks over 28,000 Jenkins situations uncovered to CVE-2024-23897—most of them from China (7,700) and america (7,368)—indicating a large assault floor that has slowly decreased from greater than 45,000 unpatched servers present in January.

 

Unpatched Jenkins servers against CVE-2024-23897
Jenkins servers unpatched in opposition to CVE-2024-23897 (Shadowserver)

In line with a Pattern Micro report, CVE-2024-23897 within the wild exploitation began in March, whereas CloudSEK claimed earlier this month {that a} menace actor often known as IntelBroker had exploited it to breach IT service supplier BORN Group.

Extra lately, Juniper Networks stated final week the RansomEXX gang exploited the vulnerability to breach the methods of Brontoo Expertise Options, which gives expertise companies to Indian banks, in late July. This ransomware assault triggered widespread disruptions to retail fee methods all through the nation.

Following these stories, CISA added the safety vulnerability to its Identified Exploited Vulnerabilities catalog on Monday, warning that menace actors are actively exploiting it in assaults.

As mandated by the binding operational directive (BOD 22-01) issued in November 2021, Federal Civilian Government Department Businesses (FCEB) companies now have three weeks till September 9 to safe Jenkins servers on their networks in opposition to ongoing CVE-2024-23897 exploitation,

Though BOD 22-01 solely applies to federal companies, CISA strongly urged all organizations to prioritize fixing this flaw and thwart potential ransomware assaults that would goal their methods.

“All these vulnerabilities are frequent assault vectors for malicious cyber actors and pose vital dangers to the federal enterprise,” the cybersecurity company warned in the present day.

US warns of Iranian hackers escalating affect operations

0


US warns of Iranian hackers escalating affect operations

The U.S. authorities is warning of elevated effort from Iran to affect upcoming elections by means of cyber operations focusing on Presidential campaigns and the American public.

In a joint assertion from the Workplace of the Director of Nationwide Intelligence (ODNI), the FBI, and the Cybersecurity and Infrastructure Safety Company (CISA), the U.S. says that Iran carried out cyberattacks in an try to realize entry to delicate data associated to U.S. elections.

The advisory underlines Iran’s intention to sow doubts concerning the integrity of democratic establishments within the U.S. and conduct aggressive cyber exercise on a number of ranges to gather intelligence.

“Iran perceives this 12 months’s elections to be significantly consequential by way of the impression they may have on its nationwide safety pursuits, rising Tehran’s inclination to attempt to form the result,” reads the general public advisory.

“We’ve noticed more and more aggressive Iranian exercise throughout this election cycle, particularly involving affect operations focusing on the American public and cyber operations focusing on Presidential campaigns.”

CISA and the FBI additionally confirmed that the latest experiences about Iranians breaching former U.S. President Trump’s marketing campaign are legitimate, attributing the assault to Iranian state-backed actors.

The incident, first reported by Politico, occurred earlier this month and concerned stealing and leaking confidential data.

A few days earlier, Microsoft’s menace intelligence workforce warned about elevated exercise from Iran focusing on entities referring to the U.S. Presidential election utilizing password spraying and spear-phishing ways.

One other side refers to misinformation unfold by means of Iranian operations, additionally highlighted within the newest CISA bulletin and recorded within the Microsoft report.

Moreover, OpenAI introduced late final week that it recognized and disrupted a covert Iranian affect operation tracked as Storm-2035, which relied on ChatGPT to generate long-form content material revealed on websites on each ends of the political spectrum, in addition to social media feedback (in English and Spanish).

Meta’s quarterly adversarial menace report for Q2 2024 ranked Iran because the second most frequent supply of international interference, after Russia. Meta recognized and disrupted 30 clusters of coordinated inauthentic conduct from Iran within the final quarter.

The U.S. authorities point out that none of that is new, as Iran and Russia are infamous for working affect operations for a few years in numerous areas on the earth.

Stakeholders and individuals concerned within the upcoming elections by means of any function are inspired to report suspicious exercise to their native FBI workplaces and CISA by means of this devoted portal.

The FBI has lately assured the general public that the safety and resiliency of voting and counting will stay unaffected even within the case of disruptive exercise focusing on the voting infrastructure, akin to ransomware assaults.